【问题标题】:Android - Changes in "Style.xml" for Listview font-sizeAndroid - Listview 字体大小的“Style.xml”更改
【发布时间】:2010-09-23 07:13:28
【问题描述】:

我为“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有办法,那么请帮助我,让我知道。

【问题讨论】:

    标签: android listview font-size android-listview


    【解决方案1】:

    AFAIK,默认 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.

    【讨论】:

    • simple_list_item_1.xml 有一个 textview,那么是否可以为 textview 提及 android:textSize 属性??
    • @Paresh Mayani:AFAIK,我们可以覆盖样式。但不是属性。我还没有研究它。如果可能。让你知道。
    • ohhkk 感谢支持,我知道我们可以通过定义自定义适配器来更改列表视图的字体大小,但如果它以“style.xml”的方式完成,那么它很好对我来说
    猜你喜欢
    • 2011-01-28
    • 1970-01-01
    • 1970-01-01
    • 2012-11-26
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多