1

以下のように「TabWidget」のスタイルを定義しました。

<style name="MyTheme" parent="@android:style/Theme.Light">
        <item name="android:tabWidgetStyle">@style/LightTabWidget</item>
</style>

<style name="LightTabWidget" parent="@android:style/Widget.TabWidget">
            <item name="android:textSize">12px</item>
</style>

TabWidget Indicator(title) フォントに font-size 12px を設定しています。

さて、私の問題: Tabwidget スタイルの変更と同じ方法で、フォントサイズを増減するために Listview のスタイルを変更したいと考えています。リストビューのカスタムレイアウトを定義することで、リストビューのフォントサイズを変更できることはわかっています。しかし、styles.xml で行う方法がある場合は、pls が私を助けて知らせてくれます。

4

1 に答える 1

2

私の知る限り、デフォルトのtab_indicator.xmlにはスタイル属性があります。しかし、デフォルトの ListView レイアウトのsimple_list_item_1.xmlにはそれがありません。だからそれは不可能です。ただし、ListView のカスタム アダプターによって実現できます。

編集: カスタムアダプターのみを使用してリストアイテムをカスタマイズできます。ArrayAdapter Documentationに記載されています。

ドキュメントから:

A ListAdapter that manages a ListView backed by an array of arbitrary objects. By default this class expects that the provided resource id references a single TextView. If you want to use a more complex layout, use the constructors that also takes a field id. That field id should reference a TextView in the larger layout resource. However the TextView is referenced, it will be filled with the toString() of each object in the array. You can add lists or arrays of custom objects. Override the toString() method of your objects to determine what text will be displayed for the item in the list. To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString() results fill the views, override getView(int, View, ViewGroup) to return the type of view you want.

于 2010-09-23T07:25:09.423 に答える