1

そのため、上部にいくつかの画像とボタンがあり、その下にいくつかのアクティビティのリストを表示するリストビューがある画面を開発しています。

デザインはこんな感じです:- デザイン

小さい画面では、上記のアイコンと画像が画面スペースを占有するため、ListView の高さが非常に小さくなります。

では、Linearlayout または ListView の高さを増やして、ユーザーがスクロールして ListView の残りの部分を表示できるようにするにはどうすればよいでしょうか。

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
         .... Other Layouts .....

     <ListView
        android:id="@+id/listArea"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="@dimen/list_padding"
        android:paddingRight="@dimen/list_padding" />
</LinearLayout>

編集:リストへのヘッダーとしてトップビューを使用しようとしましたが、EmptyViewも必要なので、ヘッダー全体とリストビューを置き換えるため、これは問題を引き起こしています

4

2 に答える 2

0

weightSumおよびlayout_weight属性を使用して、子ビューが占める親の使用可能なスペースの量を制御できます。これらを使用するには、LinearLayout などの親レイアウトがandroid:weightSum属性を取得します。各子レイアウトはandroid:layout_weight属性を取得します。ここで、すべての子の重みの合計が親の weightSum になります。さらに、各子は、layout_heightまたはlayout_widthに設定する必要があり0dpます。いずれかが重みによって決定されます。

あなたの図に基づいた例を次に示します。上の 2 つのビューがそれぞれ画面の 1/4 をListView占め、 が下半分を占めるとします。、で表す 2 つの子レイアウト、およびに追加android:weightSum="4"します。コードは次のようになります。LinearLayoutandroid:layout_weight="1"...Other Layouts...android:layout_weight="2"ListView

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

    <ImageView
        android:layout_weight="1"
        android:layout_height="0dp"
        ...some other attributes.../>

    <LinearLayout
        android:layout_weight="1"
        android:layout_height="0dp"
        android:orientation="horizontal"
        ...some other attributes...>
        ...some children of the LinearLayout...
    </LinearLayout>

    <ListView
        android:id="@+id/listArea"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingLeft="@dimen/list_padding"
        android:paddingRight="@dimen/list_padding" 
        android:layout_weight="2"/>

</LinearLayout>
于 2013-07-31T17:21:26.830 に答える