0

このマナーのAndroidでUIを作成しようとしています

Labels: tab1 | tab2 | tab3
==========v===============
Customized        ListView
      ...

しかし、私は次のマナーのあるUIを取得しています

Labels: tab1 | tab2 | tab3
==========v===============
       Customized ListView
              ...

つまり、画面の幅全体を利用できません。ラベルの下の領域は空のままです。

画面の全幅をカバーするListViewを表示したいこれを実現するにはどうすればよいですか。助けてください

これが私が使用しているサンプルコードです

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/passesBar" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:paddingLeft="10dip"
android:paddingTop="10dip" android:paddingRight="10dip"
android:paddingBottom="5dip">

<TextView android:id="@+id/passesText" android:text="@string/passes_text"
 android:layout_width="wrap_content" android:layout_height="wrap_content"
 android:textSize = "12dip">
</TextView>


<TabHost android:id="@+id/passesTabHost"
android:layout_toRightOf="@id/passesText"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">

<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">

<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content">
    </TabWidget>
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@android:id/tabcontent">
    <ListView android:id="@+id/passesList" android:layout_below="@+id/passesBar"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:footerDividersEnabled="true"
    android:listSelector="@drawable/passes_list_item_custom_selector">
    </ListView>         

</FrameLayout>
</LinearLayout>
</TabHost>

ありがとうニキル

4

1 に答える 1

0

あなたのレイアウトxmlでこれを試してください:

  1. カスタマイズされたタグを LinearLayout でラップします (まだ LinearLayout 自体でない場合)。LinearLayout タグに、android:layout_width=0android:layout_height=wrap_content、 を設定します。android:weight=1android:gravity=left
  2. ListView タグについても、まだない場合は LinearLayout でラップし、android:layout_width=0android:layout_height=wrap_content、およびandroid:weight=3を LinearLayout タグに設定します。

これにより、基本的に、ListView の幅がカスタマイズされた幅の 3 倍に比例します。また、重力を設定すると、カスタマイズされたビューが画面の左側にくっつきます。

これについて教えてくれるアンドロイドのドキュメントからの小さな宝石は次のとおりです。

ヒント: 画面に比例したサイズのレイアウトを作成するには、layout_width 属性と layout_height 属性を fill_parent に設定してコンテナ ビュー グループ オブジェクトを作成します。子の高さまたは幅を 0 (ゼロ) に割り当てます。次に、それぞれの画面の比率に応じて、各子に相対的な重み値を割り当てます。

私はここから得ました。

于 2011-10-26T00:54:31.420 に答える