可以为多个片段做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个片段???是的,你们都知道它可以挽救记忆。
答案 0 :(得分:1)
是的,您可以根据需要在Layout
和Activities
中使用相同的Fragments