设置ListView的TEXTSIZE [英] set the textsize of a listview

查看:216
本文介绍了设置ListView的TEXTSIZE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义列表视图,并定义了一个风格吧。我不能够改变列表视图项目的TEXTSIZE。我试图去改变它通过布局,以便它可以根据设备动态变化。

I have a custom listview and have defined a style for it. I am not able to change the textsize of the items on listview. I am trying to change it through layout so that it can dynamically change depending on device.

styles.xml

styles.xml

<style parent="@android:attr/listViewStyle" name="ListStyle">
    <item name="android:background">@android:color/white</item>
    <item name="android:divider">@drawable/divider</item>
    <item name="android:textSize">26dp</item>
    <item name="android:textStyle">bold</item>
</style>

XML布局

<TvList style="ListStyle"
     android:id="@+id/mainview" 
    android:layout_height="300dp"
    android:layout_width="wrap_content" />

我知道,我可以使用 setTextSize 在我的code来改变字体大小。但我想改变它应用样式。
关于如何去改变它有什么建议?

I know that i can use setTextSize in my code for changing the font size . But i want to change it applying styles. Any suggestions on how to go about changing it?

感谢

推荐答案

在列表视图中的文本的大小由ListView的适配器的项目资源定义。如果您创建的列表视图项自定义视图并定义一个TextView,你可以在文本视图中更改字体的大小,将在列表中的每个项目定义文本的大小。

The size of the text within the List View is defined by the ListView's adapter's item resource. If you create a custom view for the list view item and define a TextView, you can change the size of the font within that text view, which will define the size of the text in each item within the List.

这篇关于设置ListView的TEXTSIZE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆