tfh*_*tfh 3 android themes styles colors spinner
我有一个Spinner并使用ArrayAdapter.在适配器中我使用"android.R.layout.simple_list_item_1",如下所示:
spinnerControlObjectType.setAdapter(new ArrayAdapter(getApplicationContext, android.R.layout.simple_list_item_1, list))
我查看了android.R.layout.simple_list_item_1并看到它有这样的文本样式:
android:textAppearance="?android:attr/textAppearanceListItemSmall"
我想在我的主题中覆盖"textAppearanceListItemSmall"以赋予它不同的颜色,我该怎么做?我不想继承任何东西或编写代码样板.我确信有一种方法可以改变颜色,只更改theme.xml.
在android文档中,它写成:'...引用一个样式属性实质上说,"在当前主题中使用由此属性定义的样式."......(http://developer.android.com /guide/topics/resources/accessing-resources.html#ReferencesToThemeAttributes).他们说"已定义"和"在当前主题中" - 我如何在当前主题中定义它?让我疯了......
小智 5
您应该在主题中覆盖该属性,在此示例中,我使用AppCompat主题作为父级,但您可以将其更改为任何其他主题.根据您的需要,您应该为不同版本的Android制作主题和样式资源:
<style name="MyTheme" parent="Theme.AppCompat.Light">
    <item name="android:textAppearanceListItemSmall">@style/MySpinnerStyle</item>
</style>
<style name="MySpinnerStyle" parent="TextAppearance.AppCompat.Subhead">
    <item name="android:textSize">13sp</item>
    <item name="android:textColor">@color/white</item>
</style>
| 归档时间: | 
 | 
| 查看次数: | 13124 次 | 
| 最近记录: |