2013-07-28 2 views
0

Im пытается иметь макет с 3 слоями. Im использует 3 linearlayouts, в которых один из них является списком, но мой нижний Linearlayout не появляется на экране.Android 3 Layers Layout with listview

Мне нужно: Вверху: Горизонтальная линейная схема | В центре: Listview | На Дно: Горизонтальная линейная Компоновка

Im используя этот код:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/BackGroundColor" 
    android:orientation="vertical" 
    android:scaleType="center" > 

    <LinearLayout 
     android:id="@+id/titleLayout" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:background="@color/titleBgColor" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/filterButton" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="left" 
      android:layout_weight="0" 
      android:background="@drawable/filtericon" /> 

     <TextView 
      android:id="@+id/sectionTitle" 
      style="@style/sectionTitle" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="(blank)" /> 

     <Button 
      android:id="@+id/addCatButton" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="right" 
      android:layout_weight="0" 
      android:background="@drawable/effect_button_add_cat_click" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_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/listview_style_list_selector" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/bottomLayout" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:background="@color/titleBgColor" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/optionsButton" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="left" 
      android:layout_weight="0" 
      android:background="@drawable/filtericon" /> 

     <TextView 
      android:id="@+id/totalValue" 
      style="@style/sectionTitle" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="66,00€" /> 

     <Button 
      android:id="@+id/savExpIncValues" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="right" 
      android:layout_weight="0" 
      android:background="@drawable/effect_button_add_cat_click" /> 
    </LinearLayout> 

</LinearLayout> 

Что не так? спасибо

+0

Что показывает ур logcat? –

+0

вставьте свой код Java вместе с вашей трассировкой logcat, я думаю, что это поможет решить вопрос –

+0

. Я понял, что заставило закрыть. но теперь проблема другая. Моя нижняя компоновка не отображается на экране. У меня есть мой верхний макет, список в центре, но не нижний макет. Я отредактировал код выше без ошибки «Force Close» –

ответ

1

Я исправил макет для вас. Попробуйте:

<?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" 
    android:background="@color/BackGroundColor" 
    android:orientation="vertical" 
    android:scaleType="center" > 

    <LinearLayout 
     android:layout_alignParentTop="true" 
     android:id="@+id/titleLayout" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:background="@color/titleBgColor" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/filterButton" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="left" 
      android:layout_weight="0" 
      android:background="@drawable/filtericon" /> 

     <TextView 
      android:id="@+id/sectionTitle" 
      style="@style/sectionTitle" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="(blank)" /> 

     <Button 
      android:id="@+id/addCatButton" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="right" 
      android:layout_weight="0" 
      android:background="@drawable/effect_button_add_cat_click" /> 
    </LinearLayout> 

    <ListView 
     android:layout_above="@+id/bottomLayout" 
     android:layout_below="@+id/titleLayout" 
     android:id="@+id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:divider="#b5b5b5" 
     android:dividerHeight="1dp" 
     android:listSelector="@drawable/listview_style_list_selector" 
     /> 

    <LinearLayout 
     android:layout_alignParentBottom="true" 
     android:id="@+id/bottomLayout" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" 
     android:background="@color/titleBgColor" 
     android:orientation="horizontal" > 

     <ImageButton 
      android:id="@+id/optionsButton" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="left" 
      android:layout_weight="0" 
      android:background="@drawable/filtericon" /> 

     <TextView 
      android:id="@+id/totalValue" 
      style="@style/sectionTitle" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="66,00€" /> 

     <Button 
      android:id="@+id/savExpIncValues" 
      android:layout_width="33dp" 
      android:layout_height="33dp" 
      android:layout_gravity="right" 
      android:layout_weight="0" 
      android:background="@drawable/effect_button_add_cat_click" /> 
    </LinearLayout> 

</RelativeLayout> 
+0

работает как шарм. благодаря –

0

Высота вашего второго макета установлена ​​как match_parent, измените ее на wrap_content или с фиксированным размером. Но я настоятельно рекомендую вам использовать свойство веса, чтобы установить высоту 3 раскладок таким образом:

<!-- your first layout --> 
    <LinearLayout 
     android:id="@+id/titleLayout" 
     android:layout_width="match_parent" 
     android:layout_height="35dp"... > 
    ... 
    </LinearLayout> 

    <!-- your second layout --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="vertical" > 
    ... 
    </LinearLayout> 

    <!-- your third layout --> 
    <LinearLayout 
     android:id="@+id/bottomLayout" 
     android:layout_width="match_parent" 
     android:layout_height="35dp" ..> 
    ... 
    </LinearLayout> 

также установить все ориентации LinearLayout к вертикали.

+0

. Я сделал это, и теперь у меня есть верхний макет, нижний макет второй и нет списка. Без этого изменения у меня был верхний макет, второй - второй, а нижний макет. –