Android开发总体布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <!-- head -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <!-- 引入布局 也是xml布局文件-->
        <include layout="@layout/head"/>
    </LinearLayout>

    <!-- 中间 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">
        <!-- 引入布局 也是xml布局文件-->
        <include layout="@layout/middle"/>
    </LinearLayout>

    <!-- 引入其他布局 也是xml布局文件-->
    <!--  …… -->

    <!-- 底部 -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    <!-- 引入布局 也是xml布局文件-->
       <include layout="@layout/bottom"/>
    </LinearLayout>

</LinearLayout>    

先总体布局,有的布局可以分为几部分,比如头部、中部、底部,代码如上。

用include layout=""在布局中引入其他的布局,这样结构就比较清楚,方便布局模块化,复用布局。

简单的,可以直接一个xml文件布局。

posted @ 2019-06-17 11:26  和心  阅读(395)  评论(0编辑  收藏  举报