ThemeUtil - OneUIProject/OneUI-Design-Library GitHub Wiki

The default color of the theme is the same blue as Samsung uses in their apps and like Samsung, you too can use different colors for your apps which will apply on the entire app and even on the AppIcon. In this library there are three different ways to do that and all three can be used simultaneously:

1. Entire App (static)

This methode will apply the color theme on the entire app and on the app icon, for this you simply need to add these three colors in your colors.xml:

<color name="primary_color">...</color>
<color name="secondary_color">...</color>
<color name="primary_dark_color">...</color>

These three colors should approximately have the same color but with a different brightness. secondary_color the brightest, then primary_color and the darkest primary_dark_color. You can also try out some color combinations in the sample app with the color picker.

Here are some presets (if you want I can make more):

  • #f3a425 Yellow like MyFiles App (also used in FreshHub):
<color name="primary_color">#fff3a425</color>
<color name="secondary_color">#ffffb949</color>
<color name="primary_dark_color">#ffbd7800</color>
  • #008577 Dark green like Calendar App:
<color name="primary_color">#ff008577</color>
<color name="secondary_color">#ff009e7c</color>
<color name="primary_dark_color">#ff00574b</color>
  • #68b31a Light green like Calculator App:
<color name="primary_color">#ff68b31a</color>
<color name="secondary_color">#ff7fa87f</color>
<color name="primary_dark_color">#ff569415</color>
  • #ff034A Light red which I personally like (especially in dark mode):
<color name="primary_color">#ffff034a</color>
<color name="secondary_color">#ffff3d67</color>
<color name="primary_dark_color">#ffde0043</color>

2. Single/Multiple activities (static)

If you want to use different colors for a single (or multiple, but not all) activities, this is also possible. The difference here is that this will only apply for the activities you want. Add the three colors in a theme in themes.xml:

<style name="MyThemeName" parent="OneUITheme">
    <item name="colorPrimary">#fff3a425</item>
    <item name="colorSecondary">#ffffb949</item>
    <item name="colorPrimaryDark">#ffbd7800</item>
</style>

Then apply it on the activities you want with android:theme="@style/MyThemeName" in AndroidManifest.xml.

3. Via Code (dynamic)

This util class allows you to change the color of your theme dynamically within your app. It's based on this idea. In your activity onCreate add this line at the top before super.onCreate(...):

new ThemeUtil(this);

This will apply the color theme at launch. If you want to change the color you can use these functions:

ThemeUtil.setColor(Activity activity, int red, int green, int blue)
ThemeUtil.setColor(Activity activity, float red, float green, float blue)
ThemeUtil.setColor(Activity activity, float[] hsv)

The color you apply with these functions will apply on every activity with new ThemeUtil(this) at the top. If you are using ThemeUtil and you want to enable/disable Dark theme you'll have to do it with these methods:

// mode: DARK_MODE_AUTO; DARK_MODE_DISABLED; DARK_MODE_ENABLED
public static void setDarkMode(AppCompatActivity activity, int mode)
public static int getDarkMode(Context context)
⚠️ **GitHub.com Fallback** ⚠️