安卓中xml中包含另一个布局,使用include

来源:互联网 发布:有什么人工智能机器人 编辑:程序博客网 时间:2024/06/06 17:52

定义好一个布局命名为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"    />



0 0
原创粉丝点击