Giter Club home page Giter Club logo

Comments (9)

garretyoder avatar garretyoder commented on August 28, 2024

Post your custom theme.

from colorful.

tcqq avatar tcqq commented on August 28, 2024
<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.

garretyoder avatar garretyoder commented on August 28, 2024

Remove color primary/primarydark/accent from your theme and leave just text color.

Don't re-set values Colorful is already setting.

from colorful.

tcqq avatar tcqq commented on August 28, 2024

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.

garretyoder avatar garretyoder commented on August 28, 2024

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.

tcqq avatar tcqq commented on August 28, 2024

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.

garretyoder avatar garretyoder commented on August 28, 2024

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.

tcqq avatar tcqq commented on August 28, 2024

After switching theme

tim 20180617155028

Before switching theme

tim 20180617155031

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.

garretyoder avatar garretyoder commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.