Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Android Material Components version from 1.0.0 to 1.1.0, color all messed up

After I update the material components version from 1.0.0 to 1.1.1, the colors inside app messed up. For example color accent not working, buttons color not applied, bottom navigation view become black color.. Please help, thanks in advance!

values/style.xml (style here not working):

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Button" parent="@style/Widget.MaterialComponents.Button">
    <item name="cornerRadius">@dimen/button_radius</item>
    <item name="fontFamily">@font/lato_regular_400</item>
    <item name="android:textAllCaps">false</item>
</style>
<style name="Button.Next">
    <item name="fontFamily">@font/lato_bold_700</item>
    <item name="android:textSize">@dimen/_18pxsp</item>
    <item name="android:textAllCaps">false</item>
    <item name="cornerRadius">@dimen/_40sdp</item>
</style>

values-v23/style.xml (style here is working):

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowLightStatusBar">true</item>
</style>

button.xml:

<com.google.android.material.button.MaterialButton
        android:id="@+id/btn_save"
        style="@style/Button.Next"
        android:layout_width="@dimen/button_width"
        android:onClick="@{click}"
        android:layout_height="@dimen/button_height"
        android:layout_marginBottom="@dimen/_20pxdp"
        android:text="@{buttonText}" />

But even the v23 style is working, the colors all still very strange, compare to before update material components version. Very hard to apply back the same colors.

like image 596
yao Avatar asked Nov 12 '19 10:11

yao


1 Answers

We have officially Material Components 1.1.0

Try to use parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge"

Take a look at documentation. https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md#bridge-themes-bridge-themes

If you cannot change your theme to inherit from a Material Components theme, you can inherit from a Material Components Bridge theme.

<style name="Theme.MyApp" parent="**Theme.MaterialComponents.Light.Bridge**">
    <!-- ... -->
</style>

In your case change:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">

To:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge">
like image 125
adek Avatar answered Nov 08 '22 09:11

adek