0

OK/ボタンを一番下に固定したいCancel(画面に表示できる項目がリストにある場合でも)。現在の外観は次のとおりです。

ここに画像の説明を入力

ボタンは下ではなく上にあります。

ボタンを含むレイアウト:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:orientation="horizontal"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:stretchColumns="true"
             android:id="@+id/buttons_layout">    
    <TableRow>    
        <Button
            android:id="@+id/btnOK"
            android:background="@color/pomegranate"
            android:text="OK"
            android:layout_gravity="fill_horizontal"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>        
        <Button
            android:id="@+id/btnCancel"
            android:background="@color/wet_asphalt"
            android:text="Cancel"
            android:layout_weight="1"
            android:layout_gravity="fill_horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    </TableRow>
</TableLayout>

複合レイアウト:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <ListView android:id="@+id/options_list"
              android:layout_width="fill_parent"
              android:layout_height="match_parent">
    </ListView>
    <include layout="@id/buttons_layout"
             android:layout_alignParentBottom="true"
             android:layout_height="match_parent"
             android:layout_below="@id/options_list"/>
</RelativeLayout>

http://developer.android.com/guide/topics/ui/layout/relative.htmlで読んだガイドラインに従いました

私はこの答えを試しました - https://stackoverflow.com/a/6285438/168719 - それは私を助けませんでした。

リストビューは高さを「認識」していないため、機能しない可能性があるのではないかと考えたため、ボタンレイアウトも配置場所を認識していません。しかし、ListView の高さを 100dp などの任意の値に設定することで除外しました。ボタンはまだその上に重ねられています。

すべてのレイアウト属性をいじりましたが、うまくいきません。

解決策とは別に、なぜ私のものがうまくいかないのか知りたいです...

4

5 に答える 5

1

レイアウトは次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <ListView android:id="@+id/options_list"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_above="@+id/layout_buttons" >
    </ListView>
    <include android:id="@+id/layout_buttons"
             layout="@id/buttons_layout"
             android:layout_alignParentBottom="true"
             android:layout_height="wrap_parent"
             android:layout_width="wrap_content"/>
</RelativeLayout>
于 2013-10-27T19:07:32.543 に答える
0

タブを使用してそれを行うことができます

このチュートリアルを見ることができます

Android タブ レイアウトのチュートリアル

于 2013-10-27T19:10:29.777 に答える
0

このように使用してみることができます

<relativelayout1>

<relativelayout2 specify layout below listview with id="list">
    <button1>
    <button2>
</relativelayout2>


<listview id="list">
</listview>

</relativelayout1>

これにより、リストの長さに関係なく、リストの下に常にボタンが表示されます。リストの下にスクロールリストと静的ボタンを配置できます

于 2013-10-27T19:11:45.237 に答える