在主题中定义TabLayout样式 [英] Define TabLayout style in theme
本文介绍了在主题中定义TabLayout样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序中有两种不同的TabLayout
样式:
I have two different styles of TabLayout
in my app:
<style name="TabLayoutPower" parent="Widget.Design.TabLayout">
<item name="tabSelectedTextColor">@android:color/white</item>
<item name="tabTextColor">@android:color/white</item>
</style>
<style name="TabLayoutFree" parent="Widget.Design.TabLayout">
<item name="tabSelectedTextColor">@android:color/black</item>
<item name="tabTextColor">@android:color/black</item>
</style>
如何为主题定义默认的TabLayout
样式?我找不到任何信息应使用哪个项目名称来构建主题.我想以添加列表视图的相同方式添加TabLayout:
How can I define the default TabLayout
style for a theme? I cannot find any info which item name should I use to build my theme. I'd like to add the TabLayout the same way I added my listview:
<style name="Free" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/main_red</item>
<item name="android:windowBackground">@color/main_bg_light</item>
<item name="android:listViewStyle">@style/MyListView</item>
</style>
推荐答案
对于支持库TabLayout
,您可以在主题中设置tabStyle
属性:
For Support Library TabLayout
, you can set tabStyle
attribute in your theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- ... -->
<item name="tabStyle">@style/AppTheme.TabLayout</item>
</style>
<style name="AppTheme.TabLayout" parent="Widget.Design.TabLayout">
<item name="tabSelectedTextColor">@android:color/white</item>
<item name="tabTextColor">@android:color/white</item>
</style>
这篇关于在主题中定义TabLayout样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文