多个片段的1个布局?那可能吗?

时间:2016-08-18 13:03:39

标签: android android-layout android-fragments

可以为多个片段做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个片段???是的,你们都知道它可以挽救记忆。

1 个答案:

答案 0 :(得分:1)

是的,您可以根据需要在LayoutActivities中使用相同的Fragments