Comments (9)
Post your custom theme.
from colorful.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/grey_900</item>
</style>
from colorful.
Remove color primary/primarydark/accent from your theme and leave just text color.
Don't re-set values Colorful is already setting.
from colorful.
When I remove color primary/primarydark/accent from the theme, but now color of the interface are not using ThemeColor.GREEN and ThemeColor.BLUE, now color is the default color of "Theme.AppCompat.Light.NoActionBar".
from colorful.
Ah I see your problem.
Remove the parent item. When you're merging a style don't use a parent theme because then you will override all the values Colorful just set.
from colorful.
When I remove the parent item, the default color is now correct. But when I dynamically change setCustomThemeOverride
, the textColorPrimary
color does not work.
Colorful().edit()
.setPrimaryColor(ThemeColor.RED)
.setAccentColor(ThemeColor.BLUE)
.setDarkTheme(false)
.setCustomThemeOverride(R.style.AppThemeNight)
.apply(this) {
recreate()
}
<style name="AppThemeNight">
<item name="android:textColorPrimary">#FFEB3B</item>
</style>
from colorful.
Hmm. This seems like just weirdness with Android's style engine. What happens if you use a custom base theme instead of a override? Note you'll need a parent theme to do the base theme. The order of operations for Colorful is
Base Theme -> Colorful Colors -> Custom Override
Latter overrides the former.
from colorful.
After switching theme
Before switching theme
Code
Application.kt
val defaults = Defaults(
ThemeColor.GREEN,
ThemeColor.BLUE,
false,
false,
R.style.BaseTheme)
initColorful(this, defaults)
MainActivity.kt
class MainActivity : CAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
button_switch_theme.setOnClickListener {
Colorful().edit()
.setCustomThemeOverride(R.style.CustomTheme)
.apply(this) {
recreate()
}
}
}
}
Style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="android:textColorPrimary">#D50000</item>
</style>
<style name="BaseTheme">
<item name="android:textColorPrimary">#D50000</item>
</style>
<style name="CustomTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">#D50000</item>
</style>
</resources>
from colorful.
I've been very busy and haven't gotten time to test this yet, but I plan on testing if I can reproduce this tonight.
from colorful.
Related Issues (20)
- Not working after app restart HOT 4
- Use custom color HOT 11
- Load style resources by name not by id
- "setPrimaryColor" and "setCustomThemeOverride" conflict HOT 12
- Disabled override how to use light/dark theme HOT 1
- Request to add color HOT 3
- Use THEME_MATERIAL appear error log HOT 10
- Colorful has error when start strict mode HOT 7
- Sample code for use without kotlin HOT 5
- Compile issue error: style attribute 'attr/colorSecondary HOT 11
- Does Proguard settings mentioned in document?
- Material Drawer Theming Support? HOT 3
- Migrate to AndroidX HOT 1
- How to customize views in theme?
- ThemeEditor public apply method needs null check
- startSupportActionMode works not propertly with Colorful
- ERROR: Failed to resolve: com.github.garretyoder:Colorful:2.3.4 HOT 1
- R styles not found on API 19 HOT 1
- App bar and Statusbar need same color HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from colorful.