2010-12-15 3 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

Почему у вас есть ваш ListView в LinearLayout? С размером от wrap_content? Это не имеет большого смысла. Просто добавьте ListView и установите layout_height="fill_parent". Это должно занять все занимаемое пространство.

2
android:orientation="vertical" 

на обоих LinearLayout (ы) Вы действительно не нужен второй, потому что у него есть только один ребенок. Но если вы должны установить вес = 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

Смежные вопросы