Open tcqq opened 5 years ago
If the theme has been modified, Cyanea will call setTheme
with a Cyanea based style in Activity#onCreate
. Unfortunately this will modify current styles that you might have set.
I will need to come up with a better alternative, but for now, you will have to create 4 styles and override getThemeResId
in your activity. This way, you can specify which style Cyanea should use.
Example:
In res/values/styles.xml
:
<style name="AppTheme.Light.DarkActionBar" parent="Theme.Cyanea.Light.DarkActionBar">
<item name="android:textColorPrimary">@color/my_primary_text_color</item>
</style>
<style name="AppTheme.Light" parent="Theme.Cyanea.Light">
<item name="android:textColorPrimary">@color/my_primary_text_color</item>
</style>
<style name="AppTheme.Dark" parent="Theme.Cyanea.Dark">
<item name="android:textColorPrimary">@color/my_primary_text_color</item>
</style>
<style name="AppTheme.Dark.LightActionBar" parent="Theme.Cyanea.Dark.LightActionBar">
<item name="android:textColorPrimary">@color/my_primary_text_color</item>
</style>
Then, in your activity:
class MainActivity : CyaneaAppCompatActivity() {
/**
* Get the correct style for Cyanea
*/
@get:StyleRes
private val actionBarTheme: Int
get() = when (cyanea.baseTheme) {
DARK ->
if (cyanea.isActionBarLight)
R.style.AppTheme_Dark_LightActionBar
else
R.style.AppTheme_Dark
LIGHT ->
if (cyanea.isActionBarDark)
R.style.AppTheme_Light_DarkActionBar
else
R.style.AppTheme_Light
}
override fun getThemeResId(): Int = actionBarTheme
}
I want to overwrite the textColorPrimary color to red. When I change the color, the textColorPrimary in the Android Studio preview is red (the correct effect), but the effect of running the display is black, and the color of textColorPrimary has not changed. This problem also exists in the Colorful library. How can I fix this problem?