定义好一个布局命名为goodsprise:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#006000" android:id="@+id/rela1"> <TextView android:id="@+id/addText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="旬会席" /> <TextView android:id="@+id/addText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="7000円" android:layout_below="@+id/addText1" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginLeft="22dp" android:layout_marginStart="22dp" /> </RelativeLayout>
在另一个布局中使用content中使用:
<include android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="0" android:layout_weight="1" android:id="@+id/inclu1" layout="@layout/goodsprise" android:layout_margin="1dp" />