2012-05-01 4 views
3

リストビューとボタンがレイアウトファイルに表示されていますが、リストビューが画面いっぱいになるとボタンが消えてしまいます。リストビューのフルボタンが消えます

<?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="wrap_content" 
android:orientation="vertical" > 

<ListView 
android:id="@+id/myListView" 
android:layout_width = "fill_parent" 
android:layout_height = "wrap_content"/> 

<Button 
    android:id="@+id/back_button" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="20dip" 
    android:text="@string/backButton_label" /> 

</LinearLayout> 
+0

単に画面から離れていますか?ボタンをリストの上に置くとどうなりますか? – Sam

+0

私はそれが画面上に残ると思うだろうが、それは醜い見えるだろう –

答えて

2

総レイアウトの高さの割合として0dpおよび重量の高さを有し、それぞれが独自のLinearLayoutListViewButton両方をラップしてみてください。

例では、次のようにレイアウトの90%、Buttonを10%とします。それに応じて値を調整します。

<?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="wrap_content" 
    android:orientation="vertical" > 

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

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.1" 
    android:orientation="vertical" > 
    <Button 
     android:id="@+id/back_button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="20dip" 
     android:text="@string/backButton_label" /> 
    </LinearLayout> 

</LinearLayout> 
関連する問題