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 的样式以增加/减少字体大小。我知道我们可以通过为 Listview 定义自定义布局来修改 listview 的字体大小。但是,如果styles.xml 有办法,那么请帮助我并让我知道。

4

1 回答 1

2

AFAIK,默认tab_indicator.xml具有样式属性。但是对于默认的 ListView 布局simple_list_item_1.xml没有它。所以这是不可能的。但是您可以通过 ListView 的自定义适配器来实现它。

编辑: 您只能使用自定义适配器来自定义列表项。它在ArrayAdapter 文档中提到。

从文档:

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 回答