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
[Button] android:background not working #889
Comments
Hi @DreamerLeon, could you try with a newer version of the library? If possible, please provide a sample app to reproduce this issue. It can help us to understand the problem and make a decision to resolve it faster. Thanks. |
New version(1.2.0-alpha03) also has this problem , I will write a demo Later on and post on github ,Thanks for your answer. |
MDCIssueDemo |
Thanks @DreamerLeon for the demo. This is a known issue. Currently the solution to this is to set the background programmatically. We are working on a solution for the xml attribute. Hope that it can land soon. |
Thx for your answer! |
hope next beta fix this . I need add boilerplate code for background! |
I am using latest version com.google.android.material:material:1.2.0-alpha05. |
Any update of this? |
@diegoalvis This problem still exits,I hope someone can fix it |
Fixed in 309d718 |
Hi, could you make a new alpha release with this fix? It's quite important for me and others :) |
Stills' waiting.🙄 |
@pejman-74 In case it's useful, my workaround is to use a FrameLayout with an ImageButton and a (Material)TextView |
Stay tuned, a new alpha release is coming this week. |
it worked well with the update on: |
Friday release! 🤩🙈 |
Updated to : com.google.android.material:material:1.2.0-alpha06 |
Still not working for me.
background_button.xml:
background_button_text_color.xml:
I am getting a black background instead of white when the button is pressed. Not sure what I'm doing wrong. Any help? I am on Update: was able to get it working thanks to the help of a couple folks on stackoverflow. |
Using |
@nickruddeni Check the update on the bottom of my post. Might help. |
the same problem. Using |
solved with |
I think this is because we still set So if you are using a custom Or, if all you care about is the color of the button, then you can just use |
Worked like magic, thank you for telling +1 |
Still not working for me , I set a drawable |
It doesn't work for drawables, you can only use to change colors and it clears says "tint" :) |
It didn't work for drawables for me either, see my hack comment above
…________________________________
De: V Bhavna Haritsa <notifications@github.com>
Enviado: lunes, 11 de mayo de 2020 9:24
Para: material-components/material-components-android <material-components-android@noreply.github.com>
CC: Alejandro H. Cruz <j.alejandro_1093@hotmail.com>; Comment <comment@noreply.github.com>
Asunto: Re: [material-components/material-components-android] [Button] android:background not working (#889)
solved with app:backgroundTint
Still not working for me , I set a drawable
It doesn't work for drawables, you can only use to change colors and it clears says "tint" :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#889 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAOQVOVOJNCN5KW2RVTKV33RQ6R2TANCNFSM4KEUAY2A>.
|
@cutiko If you want to use a custom drawable for CheckBox and disable the Material tinting, can you try setting |
@mecoFarid please share a sample app and explain the expected result and observed result. |
@wcshi Here is the sample project. https://github.com/mecoFarid/MaterialCompButton Observed result: Steps to get the expected result:
|
Did you follow the steps in #889 (comment)? |
@wcshi It worked, thank you. I love how android SDK is becoming more about painful, hidden workarounds than a smooth development kit. |
It's working in latest release 1.2.0 |
I still need set |
still not working Library version: 1.2.0 |
This doesn't work for me on 1.2.1. This is what I've tried:
Either way, the button is just black and the drawable isn't visible. |
@smithaaron this bug is for MaterialButton not for FloatingActionButton |
@ymarian I think they are related. I just updated to Material 1.2.1, and FAB was working like a charm, after the update it is not working properly |
This problem continues, |
If you are concerned only about the
|
Ya thanks it works |
Change Theme in styles from Theme.MaterialComponents.DayNight.DarkActionBar to Theme.MaterialComponents.DayNight.DarkActionBar.Bridge |
I changed from Button to com.google.android.material.button.MaterialButton and all was well in that the theme colors were applied. |
fix it by change Theme.MaterialComponents.NoActionBar to Theme.MaterialComponents.NoActionBar.Bridge and it will work |
just use for xml app:backgroundTint="@color/purple_700" that's it and it will be change the button color No need to change the Theme it should be |
this also works for me, didn't need to add more xml / java code |
still not works for me this is code for my button `
` |
To work around this issue, do one of the following:
Both the solutions works fine. |
Theme.MaterialComponents.DayNight.DarkActionBar.Bridge |
Theme.MaterialComponents.DayNight.DarkActionBar |
c# ms vs 2022 |
In my app I used gradient on button, it runs but sometimes button is shown in normal button color. Can anyone tell me what is the problem? |
Well the problem is that when I use drawables it looks okay on the xml design but once I install the app on my phone the color of the button goes back to default, althought the shape stays as I want it but the color ... |
still exist on 1.5.0 |
Thanks but it's resolved |
Description: after I change my app them to
Theme.MaterialComponents.NoActionBar
, In my xml fileButton
label'sandroid:background="@drawable/login_btn_bg"
not working,and I can't set others color、shape or selector,they are not work.Expected behavior:
Button
label'sandroid:background=
can normal work , when I set my app them toTheme.MaterialComponents.NoActionBar
or others Material themsSource code:
<style name="CommonAppTheme" parent="Theme.MaterialComponents.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/common_colorPrimary</item> <item name="colorPrimaryDark">@color/common_colorPrimaryDark</item> <item name="colorAccent">@color/common_colorAccent</item> <item name="buttonStyle">@style/commonButtonStyle</item> <item name="materialButtonStyle">@style/commonButtonStyle</item> </style>
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="commonButtonStyle" parent="Widget.MaterialComponents.Button"> <item name="android:insetTop">0dp</item> <item name="android:insetBottom">0dp</item> <item name="android:insetLeft">0dp</item> <item name="android:insetRight">0dp</item> <item name="android:minHeight">0dp</item> <item name="android:textColor">@color/common_text_color</item> </style> </resources>
<Button android:id="@+id/btnLogin" android:layout_width="match_parent" android:layout_height="38dp" android:layout_marginLeft="31dp" android:layout_marginTop="61dp" android:layout_marginRight="31dp" android:background="@drawable/btn_bg" android:gravity="center" android:text="@string/common_immediately" android:textSize="15sp" />
Android API version: Android 8.1
Material Library version: 1.0.0
Device: le pro 3
To help us triage faster, please check to make sure you are using the latest version of the library.
We also happily accept pull requests.
The text was updated successfully, but these errors were encountered: