-
-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with background and text color of buttons #523
Comments
Also, for some very strange reason, I cannot set the color of the text at either the 'ok' or 'cancel' button to be white. Not with Color.parse("#FFFFFF), not with Color.parse("white"), not with a color from colors.xml. No damn way to do that! Could there be a collision with some other library or id of color? |
This looks like a strange one. If you're running api-version >= 21, the background of the buttons is set with |
Here is my project's setup:
Also, I am using version 3.6.3 of the library, AndroidX (v. 1.0.0-rc02) and Material Components (v. 1.0.0-rc02). The previous screenshots were from the emulator. On my phone (Google Nexus 5X with Android 8.0) I get the same result. No matter if I set the color of the ok button with
or
it is always not visible. I can see though that when it is pressed, the color of the text is pink (the accent color). There is no direct or indirect assignment of the android:colorButtonNormal anywhere in my code. I have removed questionable libraries to remove the risk of them fiddling around but still no result :( Any suggestions what else to try or look at? |
Answering my own questions, the problem was caused from the use of Theme.MaterialComponents.Light.NoActionBar. It was fixed when I reverted to the use of Theme.MaterialComponents.Light.NoActionBar.Bridge which uses the new Material Components a bit more careful when playing with previous app compat elements. In a nutshell, for future generations, use 'Theme.MaterialComponents.Light.NoActionBar.Bridge' as your theme when using this library. @wdullaer Feel free to close this issue. |
So it was related to a library overwriting some values. Thanks for looking into this some more! I will track that progress in #524 and close this one. |
I would not say that this problem is resolved. Also, it seems like the bridge themes match the "old" Material design guidelines while |
+1! The button text color and the button background color are both using the accent color. So we can't see the button text. |
So this really is not my problem. As an additional workaround you can also add the following line to your own application theme <item name="viewInflaterClass">androidx.appcompat.app.AppCompatViewInflater</item> This will disable the custom Other than depending on this library, there are no other fixes for this that I can see. |
Another workaround is to overwrite the button layout. In fact, it would be enough to just set the style, as the Button is being replaced with MaterialButton regardless, which causes the issue in the first place. This will apply the new default text button style to the buttons. |
@ezet yes i think this is better than replacing the whole LayoutInflater. |
So to sum up for everyone reading this. As @ezet mentions the fix is to simply add this line to your <style name="mdtp_ActionButton.Text" parent="Widget.MaterialComponents.Button.TextButton.Dialog"/> No need for a the |
See wdullaer#523 for more information
Hello and thanks for this very nice library.
I have a strange problem that I could definitely use some help to sort things out.
I am showing a date and time picker which I am theming a bit. My problem is that the 'ok' and 'Cancel' buttons seem to get as both background color and text color the accent color of my theme.
Here are 2 screenshots and the related code:
And the time picker:
Here is my theme:
And the colors.xml:
I have removed any other library that might have been colliding with the attributes of your library.
So, my question is if you know what is causing this problem or if I can set both the background color and text color of the buttons.
Thanks :)
The text was updated successfully, but these errors were encountered: