-3
有可能爲多個碎片做一個佈局?1佈局多個片段?那可能嗎?
例如..我有一個佈局,我們叫A.XML
,我想用它在我的碎片上。有6個片段,每個片段的佈局是相同的。假設在每個片段的佈局中只使用RecycleView
。
A.XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".categoryFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvFoodCtg"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#f4f4f4"
android:layout_gravity="center"
android:layout_weight="1" />
</LinearLayout>
是可能的,如果我想只有A.XML
用我所有的6個片段???是的,你們都知道它可以節省內存。
只是延長片段,它要使用相同的佈局,從充氣要使用所有的佈局基本片段片段在其oncreateView。 –
之前問你有沒有試過? –