2013-08-25 22 views
0

我再試一次... My ListView (of my ViewFilipper) fills the parent and buttons on the bottom get hidden我(我ViewFilipper)的ListView隱藏按鈕在底部

這是我的XML:

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/layoutinclude" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" > 

    <ViewFlipper 

     android:id="@+id/flipper" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inAnimation="@anim/fade_in" 
     android:isScrollContainer="true" 
     android:outAnimation="@anim/fade_out" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:orientation="vertical" > 

      <ProgressBar 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:indeterminate="true" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/scanning" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" > 

      <ListView 
       android:id="@android:id/list" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="@dimen/list_margin" 
       android:layout_marginRight="@dimen/list_margin" 
       android:layout_weight="1" 
       android:background="?attr/listBackground" 
       android:fastScrollEnabled="true" > 
      </ListView> 

      <TextView 
       android:id="@android:id/empty" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/this_folder_is_empty" 
       android:textAppearance="?android:attr/textAppearanceMedium" /> 
     </LinearLayout> 
    </ViewFlipper> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="2" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button" /> 
</LinearLayout> 

這是我想要的結果:

enter image description here

這就是我所得到的:

enter image description here

+0

@avalancha是相似的,不一樣的......請不要關閉這個問題 –

+0

使你的父ViewGroup(你的根節點)成爲一個RelativeLayout,並在包含列表的LinearLayout上指定'android:layout_above =「@id/THE_BUTTON_CONTAINER'。然後系統將忽略列表中的所有意圖以使其更大 – avalancha

+0

@avalancha非常感謝! 1這樣做。如果您發佈了答案,我會很樂意接受它! :-))) –

回答

1

這應做到:

<?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"> 

     <Button 
       android:id="@+id/button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button"/> 

     <Button 
       android:id="@+id/button2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button"/> 
    </LinearLayout> 

    <LinearLayout 
      android:id="@+id/layoutinclude" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:layout_weight="1"> 

     <ViewFlipper 
       android:id="@+id/flipper" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inAnimation="@anim/fade_in" 
       android:isScrollContainer="true" 
       android:outAnimation="@anim/fade_out"> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:orientation="vertical"> 

       <ProgressBar 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:indeterminate="true"/> 

       <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/scanning"/> 
      </LinearLayout> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center"> 

       <ListView 
         android:id="@android:id/list" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="@dimen/list_margin" 
         android:layout_marginRight="@dimen/list_margin" 
         android:layout_weight="1" 
         android:background="?attr/listBackground" 
         android:fastScrollEnabled="true"> 
       </ListView> 

       <TextView 
         android:id="@android:id/empty" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/this_folder_is_empty" 
         android:textAppearance="?android:attr/textAppearanceMedium"/> 
      </LinearLayout> 
     </ViewFlipper> 
    </LinearLayout> 

    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

     <Button 
       android:id="@+id/button3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button"/> 

     <Button 
       android:id="@+id/button4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button"/> 
    </LinearLayout> 
</LinearLayout> 
+0

非常感謝你,avalancha解決了這個問題。不管怎樣,謝謝你!!! –

1

在過去的LinearLayout取出重量

+0

非常感謝你,avalancha解決了這個問題。不管怎樣,謝謝你!!! –