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>    

先整体布局,有的布局能够分为几部分,好比头部、中部、底部,代码如上。android

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

简单的,能够直接一个xml文件布局。布局

相关文章
相关标签/搜索