TutorialsAndroid/FilePicker

Cannot change dialgoue button color

PembaTamang opened this issue · 5 comments

I cannot change the color of the dialogue buttons what styles do I need to apply.
app parent theme - Theme.MaterialComponents.Light.DarkActionBar
dialogue - val dialogue = FilePickerDialog(activity!!,properties,R.style.mAlertDialogTheme)
style -

  <style name="mAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
        <item name="android:buttonBarNegativeButtonStyle">@style/NegativeButtonStyle1</item>
        <item name="android:buttonBarPositiveButtonStyle">@style/PositiveButtonStyle1</item>
        <item name="android:colorAccent">@color/white</item>
    </style>

    <style name="NegativeButtonStyle1" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="android:textColor">#FFFFFF</item>
    </style>

    <style name="PositiveButtonStyle1" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="android:textColor">#FFFFFF</item>
    </style>

Hi,
you can access the select button with the ids R.id.select and R.id.cancel like this:

Button select = dialog.findViewById(R.id.select); select.setTextColor(Color.BLUE);

Warning! That only works after caling dialog.show().

Disadvantage: In the method listed above, you won't see when the select button is disabled or not. To solve this, you can apply a theme to the button with select.setTextAppearance(R.style.PositiveButtonStyle). This call requires API level 23. Then you can define a color selector to apply the transparency to the color when the button is disabled.

Did you solve your problem? Can we close this issue?

yes thanks and Thank you for this library

It's not mine but yes, thank @TutorialsAndroid for this library.

Hello, @mrgames13 the solution you advised works for the initial button setup. But this does not fix the issue when user actually performs i.e., selection on any checkbox. This will re-set the text color to the themed one. Is there any good reason why the traditional styling via styles is not working?