Color selected tab with accent color when theme isn't blue

This commit is contained in:
arkon 2020-09-26 19:18:58 -04:00
parent a3c598a3e1
commit 972a595c74
5 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Based on mtrl_tabs_icon_color_selector_colored.
We want to use the accent color in some themes, but sometimes colorPrimary doesn't work well with
it (i.e. blue themes).
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorAccentOnPrimary" android:state_selected="true"/>
<item android:alpha="0.60" android:color="?attr/colorOnPrimary"/>
</selector>

View File

@ -3,5 +3,5 @@
<corners <corners
android:topLeftRadius="4dp" android:topLeftRadius="4dp"
android:topRightRadius="4dp" /> android:topRightRadius="4dp" />
<solid android:color="?attr/colorOnPrimary" /> <solid android:color="?attr/colorAccentOnPrimary" />
</shape> </shape>

View File

@ -15,5 +15,6 @@
<attr name="colorLibrarySelectionActive" format="reference|integer"/> <attr name="colorLibrarySelectionActive" format="reference|integer"/>
<attr name="colorFilterActive" format="reference|integer"/> <attr name="colorFilterActive" format="reference|integer"/>
<attr name="colorBackgroundSplash" format="reference|integer"/> <attr name="colorBackgroundSplash" format="reference|integer"/>
<attr name="colorAccentOnPrimary" format="reference|integer"/>
</resources> </resources>

View File

@ -285,6 +285,8 @@
<style name="Theme.Widget.Tabs" parent="Widget.MaterialComponents.TabLayout.Colored"> <style name="Theme.Widget.Tabs" parent="Widget.MaterialComponents.TabLayout.Colored">
<item name="tabGravity">center</item> <item name="tabGravity">center</item>
<item name="tabIndicator">@drawable/tab_indicator</item> <item name="tabIndicator">@drawable/tab_indicator</item>
<item name="tabIndicatorColor">?attr/colorAccentOnPrimary</item>
<item name="tabTextColor">@color/tabs_selector</item>
<item name="tabIndicatorFullWidth">false</item> <item name="tabIndicatorFullWidth">false</item>
<item name="tabIndicatorHeight">3dp</item> <item name="tabIndicatorHeight">3dp</item>
<item name="tabInlineLabel">true</item> <item name="tabInlineLabel">true</item>

View File

@ -17,6 +17,7 @@
<!-- Theme colors --> <!-- Theme colors -->
<item name="colorPrimary">@color/md_white_1000</item> <item name="colorPrimary">@color/md_white_1000</item>
<item name="colorOnPrimary">@color/md_black_1000</item> <item name="colorOnPrimary">@color/md_black_1000</item>
<item name="colorAccentOnPrimary">@color/colorAccentLight</item>
<item name="colorPrimaryVariant">@color/md_white_1000</item> <item name="colorPrimaryVariant">@color/md_white_1000</item>
<item name="colorSecondary">@color/colorAccentLight</item> <item name="colorSecondary">@color/colorAccentLight</item>
<item name="colorOnSecondary">@color/md_white_1000</item> <item name="colorOnSecondary">@color/md_white_1000</item>
@ -92,6 +93,7 @@
<style name="Theme.Tachiyomi.LightBlue" parent="Theme.Base"> <style name="Theme.Tachiyomi.LightBlue" parent="Theme.Base">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/textColorPrimaryDark</item> <item name="colorOnPrimary">@color/textColorPrimaryDark</item>
<item name="colorAccentOnPrimary">@color/textColorPrimaryDark</item>
<item name="colorPrimaryVariant">@color/colorPrimaryDark</item> <item name="colorPrimaryVariant">@color/colorPrimaryDark</item>
<item name="actionBarTheme">@style/Theme.Toolbar.Light</item> <item name="actionBarTheme">@style/Theme.Toolbar.Light</item>
@ -104,6 +106,7 @@
<!-- Theme colors --> <!-- Theme colors -->
<item name="colorPrimary">@color/colorDarkPrimary</item> <item name="colorPrimary">@color/colorDarkPrimary</item>
<item name="colorOnPrimary">@color/textColorPrimaryDark</item> <item name="colorOnPrimary">@color/textColorPrimaryDark</item>
<item name="colorAccentOnPrimary">@color/colorAccentDark</item>
<item name="colorPrimaryVariant">@color/colorDarkPrimary</item> <item name="colorPrimaryVariant">@color/colorDarkPrimary</item>
<item name="colorSecondary">@color/colorAccentDark</item> <item name="colorSecondary">@color/colorAccentDark</item>
<item name="colorOnSecondary">@color/textColorPrimaryDark</item> <item name="colorOnSecondary">@color/textColorPrimaryDark</item>
@ -172,6 +175,7 @@
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base.Dark"> <style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base.Dark">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorAccentOnPrimary">@color/textColorPrimaryDark</item>
<item name="colorPrimaryVariant">@color/colorPrimary</item> <item name="colorPrimaryVariant">@color/colorPrimary</item>
</style> </style>