0

特定の高さでリストビュー内のアイテムを調整したい。

ここに画像の説明を入力

私が行うアダプター: ?android:attr/listPreferredItemHeight、リストビューの高さがfill_parentの場合にうまく機能します。

<TextView
    android:id="@+id/FirstText"
    android:layout_width="wrap_content" 
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:layout_weight="1"
    android:gravity="center_vertical"
    android:paddingBottom="10dip"
    android:paddingLeft="6dip"
    android:paddingTop="12dip"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="18dip"
    android:textColor="#000000" />

<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:cacheColorHint="#ffffff"
    android:divider="#4436f2"
    android:dividerHeight="1px"
    android:scrollbars="none"
    android:fadingEdge="none"/>

しかし、リストビューの高さが特定のサイズの場合、項目が収まりません。

ここに画像の説明を入力

<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="200sp"
    android:background="#ffffff"
    android:cacheColorHint="#ffffff"
    android:divider="#4436f2"
    android:dividerHeight="1px"
    android:scrollbars="none"
    android:fadingEdge="none"/>

特定のリストビューで項目の高さを調整するにはどうすればよいですか?

4

1 に答える 1

0

そこでカスタムアダプターを使用する方が良いです。

于 2012-08-08T15:45:00.777 に答える