我的应用中有两种不同风格的TabLayout
:
<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
样式?我找不到任何信息,我应该使用哪个项目名来构建我的主题。我想像添加listview一样添加TabLayout:
<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>
答案 0 :(得分:5)
对于支持库TabLayout
,您可以在主题中设置tabStyle
属性:
<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>
答案 1 :(得分:-1)
您可以在Android主题中找到该名称 -
<item name="android:tabWidgetStyle">@style/Your.Style</item>
答案 2 :(得分:-1)
<style name="Base.Widget.Design.TabLayout" parent="">
<item name="tabSelectedTextColor">@android:color/white</item>
<item name="tabTextColor">@android:color/white</item>
</style>
<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>
<item name="android:tabWidgetStyle">@style/Base.Widget.Design.TabLayout</item>
</style>