2 sachinks SachinKS 于 2013.07.25 14:58 提问

设置三个布局作为header,body,footer

如题如何设置三个布局作为标题,文本和页脚?我用了下面的代码没实现。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"   
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
     <!-- HEADER -->
     <include android:id="@+id/top_header"
        layout="@layout/header2button"
        android:layout_alignParentTop="true" />
    <!-- BODY -->
    <LinearLayout android:id="@+id/center_body"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"         
        android:orientation="vertical" 
        android:layout_alignParentBottom="true">
        <include layout="@layout/logo_2button" />
    </LinearLayout> 
    <!-- FOOTER -->
    <LinearLayout android:id="@+id/bottom_menu"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"         
        android:orientation="vertical" 
        android:layout_alignParentBottom="true">
        <include layout="@layout/footer2button" />
    </LinearLayout>
    <!-- MAIN PART -->
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:layout_above="@id/top_header" 
        android:layout_below="@id/center_body"
        android:layout_below="@id/bottom_menu"
        android:layout_weight="1"
        android:id="@+id/sub_content_view"
        android:paddingBottom="5sp" android:background="#EAEAEA">
    </LinearLayout>
</RelativeLayout>

1个回答

Kill_it
Kill_it   2013.07.25 16:11
已采纳
<?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" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="#654321"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Header"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Main Body"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#123456"
        android:gravity="center"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Footer"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>
</LinearLayout>
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!