如何让用户选择Android中的列表视图主题? [英] How to allow users to choose themes in android list view?
问题描述
我有两个标签,标题和副标题列表视图。我想有深色和浅色背景的用户选项。标题有textAppearanceMedium和字幕都有textAppearanceSmall。我想要的风格,MyTheme.Dark有白色文字和MyTheme.Light有黑色文本。有没有办法来定义多个textAppearance属性为同一部件TextView的?
<样式名称=MyTheme.Dark>
<项目名称=机器人:windowBackground> @彩色/黑白LT; /项目>
<项目名称=机器人:colorBackground> @彩色/黑白LT; /项目>
<项目名称=机器人:背景> @彩色/黑白LT; /项目>
<项目名称=机器人:分> @色/白< /项目>
--cannot把textAppearance在这里,因为它是标题和副标题不同
< /风格>
我认为最好的办法是有不同的颜色和主题不同的布局XML。加载基于用户选择的布局XML。我不喜欢这个,但我还没有发现任何的替代品。
I have a listview with two labels, title and subtitle. I want to have dark and light background as user options. Title has textAppearanceMedium and subtitle has textAppearanceSmall. I want the style, MyTheme.Dark to have white color text and MyTheme.Light to have black color text. Is there a way to define multiple textAppearance attribute for the same TextView widget?
<style name="MyTheme.Dark">
<item name="android:windowBackground">@color/black</item>
<item name="android:colorBackground">@color/black</item>
<item name="android:background">@color/black</item>
<item name="android:divider">@color/white</item>
--cannot put textAppearance here since it is different for title and subtitle
</style>
I think best way is to have different layout xml for different colors and themes. Load the layout xml based on user choice. I do not like this but I have not found any alternatives.
这篇关于如何让用户选择Android中的列表视图主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!