0

I am using Theme.MaterialComponents.DayNight.NoActionBar as the app theme, and I am having weird issues when it comes to buttons colours and there are some spacing issues I am facing.

I have read that adding <item name="viewInflaterClass">androidx.appcompat.app.AppCompatViewInflater</item> should fix it and it does but I want to know if there is any other way to change it to work like it used to as there can be issues with this approach.

It is not just effecting date picker buttons but also DialogFragments

DatePickerDialog has blacked out buttons in androidx.fragment.app.DialogFragment

ColorPrimary is set to the button itself. Is there any other way I can overwrite this behaviour

Here is my style

    <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar.FullScreen">
        <item name="colorPrimary">@color/colorPrimary</item> // Blue
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="colorControlNormal">@color/colorControlNormal</item>
        <item name="colorControlActivated">@color/colorControlActivated</item>
        <item name="colorSwitchThumbNormal">@color/colorSwitchThumbNormal</item>
        <item name="android:textColorPrimary">@android:color/primary_text_light</item>
        <item name="android:textColorSecondary">@android:color/secondary_text_light</item>
        <item name="android:textColorPrimaryInverse">@android:color/primary_text_dark</item>
        <item name="android:windowBackground">@android:color/background_light</item>

        <item name="dialogTheme">@style/DialogStyle</item>
        <item name="alertDialogTheme">@style/AlertDialogStyle</item>

        <item name="md_positive_color">@color/dialog_positive_text</item>
        <item name="md_neutral_color">@color/dialog_neutral_text</item>
        <item name="md_negative_color">@color/dialog_negative_text</item>
//Adding the bellow line fixes it
        <item name="viewInflaterClass">androidx.appcompat.app.AppCompatViewInflater</item>
    </style>

    <style name="Theme.MaterialComponents.DayNight.NoActionBar.FullScreen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

This is how it should look, enter image description here

But looks like this with this theme

enter image description here

BRDroid
  • 3,920
  • 8
  • 65
  • 143
  • You are asking 3 different questions in the same question. – Gabriele Mariotti Oct 14 '19 at 12:20
  • For the picker check also the [`MaterialDatePicker`](https://stackoverflow.com/questions/57807103/materialdatepicker-not-working-on-android/57808145#57808145). For the `AlertDialog` the attribute to use is `materialAlertDialogTheme` and check this [post](https://stackoverflow.com/questions/57053520/change-dialog-button-color/58043299#58043299) to customize the buttons. Also add the `colorOnPrimary` on your app theme – Gabriele Mariotti Oct 14 '19 at 12:24
  • IIRC, this issue was fixed a while ago in an alpha release of the library. You can use the latest beta of the library, which should be stable enough for your needs. – Edric Oct 18 '19 at 02:22

0 Answers0