3

listViewを含むTableLayoutを作成しました。listViewのサイズをdpで設定して定義します。私の問題は、画面が小さいモバイルにアプリをアップロードすると、listViewが画面上で大きく(長く)なることです。ScrollViewを使用したくなく、その中にlistViewがあります。リストビューのサイズを同じにし、使用しているモバイルに依存しないように設定する他の方法はありますか?

listViewの画像:http ://tinypic.com/view.php?pic = 2qwhoxd&s = 6

<?xml version="1.0" encoding="utf-8"?>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bakgrunden"
android:orientation="vertical"
android:gravity="center|top"
android:stretchColumns="1"
android:weightSum="1.0" >

<TableRow>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
</TableRow> 

<TableRow
android:paddingLeft="22dp"
android:paddingRight="25dp"
android:paddingTop="15dp" >

<ListView
    android:id="@+id/latest_list"
    style="@style/CustomListView"
    android:layout_width="wrap_content"
    android:layout_height="390dp" <------- THE PROBLEM! The list gets to long for a
    android:gravity="left"/>               small-screen mobile.
</TableRow> 

</TableLayout>
4

1 に答える 1

0

小さい画面用に別のレイアウトを作成し、OSがロードするレイアウトを決定できるようにするだけです。Android Developersサイトには、次の優れたアドバイスがあります。さまざまな画面サイズのサポート

各画面のサイズを決定し(画面のサイズをピクセル単位で取得layout_weight)、適切な高さを計算することで、属性を工夫したり、実行時に高さを調整したりできます。しかし、正直なところ、いくつかの異なるレイアウトが最も簡単で将来性のあるアプローチです。

于 2012-06-17T19:08:59.903 に答える