2010-12-15 71 views
0

這是一個相當奇怪的問題,這似乎我不能不管多少次,我呆呆地看着它(所以它可能有一個明顯的答案)解決。問題是,當我有我的RelativeLayout/ActionBar佈局XML文檔中,ListView低於不想調試時在屏幕上顯示出來。這裏是我的XML的ListView不顯示下面的RelativeLayout

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <RelativeLayout 
      android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="50dip" 
      android:background="#4a8bcc" android:id="@+id/relLayout" > 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_centerVertical="true" 
        android:textSize="7pt" 
        android:textColor="#ffffff" 
        android:textStyle="bold" 
        android:layout_height="wrap_content" 
        android:text="List" android:padding="8dp" /> 

      <!-- A dividing line --> 
       <ImageView 
        android:layout_width="1px" 
        android:src="#ffffffff" 
        android:layout_height="wrap_content" 
        android:text="@string/hello" 
        android:id="@+id/bordertwo" 
        android:layout_toLeftOf="@+id/refresh" 
        android:layout_marginRight="12dip" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentTop="true" /> 

     <!-- share button --> 
       <ImageView 
        android:layout_width="25dip" 
        android:src="@drawable/ic_title_share_default" 
        android:layout_height="25dip" 
        android:text="@string/hello" 
        android:layout_marginRight="12dip" 
        android:layout_centerVertical="true" 
        android:id="@+id/refresh" 
        android:layout_toLeftOf="@+id/borderone" 
        android:scaleType="fitXY" /> 

      <!-- A dividing line --> 
       <ImageView 
        android:layout_width="wrap_content" 
        android:src="#ffffffff" 
        android:layout_height="wrap_content" 
        android:id="@+id/borderone" 
        android:layout_alignParentTop="true" 
        android:layout_marginRight="12dip" 
        android:layout_alignParentBottom="true" 
        android:layout_alignBottom="@+id/search" 
        android:text="@string/hello" 
        android:layout_toLeftOf="@+id/search" /> 

      <!-- Add friend --> 
      <ImageView 
        android:src="@drawable/ic_title_add_default" 
        android:text="@string/hello" 
        android:layout_width="25dip" 
        android:layout_alignParentRight="true" 
        android:layout_centerVertical="true" 
        android:id="@+id/search" 
        android:layout_marginRight="12dip" 
        android:layout_height="25dip" 
        android:scaleType="fitXY" /> 
    </RelativeLayout> 

    <LinearLayout 
      android:orientation="horizontal"    
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#4a8bcc" android:id="@+id/linLayout" 
      android:visibility="visible"> 

      <ListView 
       android:id="@+id/ListView01" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
     </LinearLayout> 
</LinearLayout> 

回答

1

爲什麼你有你的LinearLayoutListView?尺寸設置爲wrap_content?這沒有什麼意義。直接添加ListView,並設置layout_height="fill_parent"。這應該導致它佔用所有可用空間。

2
android:orientation="vertical" 
雙方的LinearLayout(S) 你真的不需要第二個,因爲它只有一個孩子

。但是如果你必須設置weight = 1就可以了。 的ListView應該是這樣的(你放棄的LinearLayout後)

<ListView 
      android:id="@+id/ListView01" 
      android:layout_width="fill_parent" 
      android:layout_height="0dip" 
      android:layout_weight="1.0" 
      /> 

而且閱讀更多關於佈局這裏 http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html

如果仍要佈局繞到你的列表按照此樣本 http://developer.android.com/resources/samples/ApiDemos/res/layout/list_8.html