2012-11-23 80 views
0
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/buttonLayout" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <Button 
     android:id="@+id/vehicleButton" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_weight="1" 
     android:text="Refresh" 
     android:onClick="getVehicles" /> 
     <Button 
     android:id="@+id/logoutButton" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_weight="1" 
     android:text="Logout" 
     android:onClick="logout" /> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </ListView> 

</LinearLayout> 

大家好,當上述的ListView填充了只有幾個項目,我仍然可以看到的按鈕,然而,當ListView控件中填充超過屏幕可以顯示,這些按鈕似乎在用戶界面上方「推」,並且不再可見,只有可滾動的ListView現在可見。的LinearLayout是「推」時的ListView填充

對於如何讓按鈕再次出現在更長的列表上有什麼想法嗎?

謝謝

+0

是你的完整佈局文件嗎?在佈局文件中你發佈的ListView不應該是按下按鈕吧 – Luksprog

+0

把你的按鈕作爲標題到你的列表 – njzk2

+0

這是完整的佈局文件是,th列表視圖由另一個XML文件的實例填充 – Seb

回答

0

作爲參考,我通過使用解決了這個一個以下內容:

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 
     <LinearLayout 
      android:id="@+id/buttonLayout" 
      android:layout_height="40dp" 
      android:layout_width="match_parent" 
      android:orientation="horizontal"> 
      <Button 
      android:id="@+id/vehicleButton" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:layout_weight="1" 
      android:text="Refresh" 
      android:onClick="getVehicles" /> 
      <Button 
      android:id="@+id/mapButton" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:layout_weight="1" 
      android:text="Map" /> 
      <Button 
      android:id="@+id/logoutButton" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:layout_weight="1" 
      android:text="Logout" 
      android:onClick="logout" /> 
     </LinearLayout> 
     <ListView 
      android:id="@+id/android:list" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:layout_below="@id/buttonLayout"> 
     </ListView> 
</RelativeLayout> 

因此,我使用的相對佈局,並且還增加了 機器人:layout_below =「@ ID/buttonLayout到ListView到強制它顯示在buttonLayout下面

1

嘗試將ListView包裝到LinearLayout中。你正在給按鈕添加一個權重以確保它們出現,但是當ListView呈現時,它似乎是造成這種情況的原因。讓我知道這是否有幫助。

<LinearLayout 
    android:layout_height="0" 
    android:layout_width="fill_parent" 
    android:layout_weight="0" 
    android:orientation="vertical"> 
    <ListView 
     android:id="@+id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 
    </ListView> 
</LinearLayout> 
+0

不幸的是,無論哪種方式都不幸運!仍在試圖弄清楚。 – Seb