美文网首页
自定义布局

自定义布局

作者: 在下陈小村 | 来源:发表于2018-03-02 13:20 被阅读5次

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"/>

相关文章

网友评论

      本文标题:自定义布局

      本文链接:https://www.haomeiwen.com/subject/uqzoxftx.html