1.在界面中引入另外一个界面,定义一个布局文件title.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="这是一个标题"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="编辑"/>
</LinearLayout>
然后在需要引入的界面,添加如下代码就可以了
<include layout="@layout/title"/>
网友评论