0

次のような単純な xml レイアウトをコーディングしました。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ARRAYADAPTER" />

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

<Button 
    android:id="@+button/b1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:text="NEXT"
    android:gravity="center"/>

</LinearLayout>

リストビュー内に配列アダプターを設定します。このアプリを起動すると、buttod が表示されません。私がしたいのは、レイアウトを3つの部分に分割することです: -上部のテキストビュー -中央のアダプター(スクロールあり) -ボタン(または複数)を下部に。どうすればできますか?

4

2 に答える 2

2

私はあなたのボタンがすべてのスペースを取っていると思いますandroid:layout_height="match_parent"、試してみてくださいandroid:layout_height="wrap_content"

于 2013-03-05T19:56:05.770 に答える
1

ListView宣言を次のように変更します。

<ListView
    android:id="@+listview/lw"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    />

ボタンの高さをに設定しますwrap_content

これにより、TextViewとButtonが使用しない残りのスペースを使用するようにListViewに指示されます。

于 2013-03-05T19:56:38.673 に答える