一个LinearLayout中有三个元素, 顶部一个head,底部一个footer,中间一个listView。目前出现了个问题,footer没有出现,被listView盖住了。不清楚什么问题,请牛人指点。xml如下:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" >

    <include layout="@layout/head" />
    
    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
         <include layout="@layout/main2" />
    </FrameLayout>
    
    <FrameLayout
        android:id="@+id/fragment_footer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >        <include layout="@layout/mytab" />
    </FrameLayout>
</LinearLayout>下面是layout/main2.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="#b5b5b5"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_selector" /></LinearLayout>
是不是LinearLayout用的有问题,请指点之。
还有两个小问题: 
1)fill_parent和match_parent有什么区别;
2)android:layout_gravity和android:gravity有什么区别。多谢了

解决方案 »

  1.   

    给你的三个部分添加android:layout_weight属性,顶部和底部设置0,中间设置1fill_parent和match_parent没区别android:layout_gravity和android:gravity区别在于,layout_gravity是控件相对于父控件的位置,gravity是控件中显示内容的位置
      

  2.   

    android:layout_gravity  用来设置控件相对于其父控件的布局;
    android:gravity         用来设置控件自身内容在控件中的布局;从Android2.2中match_parent和fill_parent是一个意思,match_parent更贴切。如果考虑低版本的使用情况你就需要用fill_parent了。footer被遮挡的问题,楼主可以考虑用RelativeLayout,或者在LinearLayout中为控件设置layout_weight属性
      

  3.   

    还有有问题,但是换成下面的样子就好了<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >    <include layout="@layout/head" />    <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >
            <include layout="@layout/main2" />
        </FrameLayout>    <include layout="@layout/mytab" /></LinearLayout>
    本来是想layout/mytab在运行时使用fragment技术来动态替换的。看来要重新设计设计了。不知道还有什么别的好办法么