My code:
<Button
android:id="@+id/button_one"
style="@style/ButtonStyle"
android:text="@string/button_one" />
<style name="ButtonStyle">
<item name="android:textSize">32sp</item>
<item name="android:textColor">@drawable/background_button_text_color</item>
<item name="android:background">@drawable/background_button</item
</style>
background_button.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" android:state_pressed="true" />
<item android:drawable="@android:color/transparent" android:state_pressed="false" />
</selector>
background_button_text_color.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/black" android:state_pressed="true" />
<item android:color="@android:color/white" android:state_pressed="false" />
</selector>
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 1.2.0-alpha06
and using Theme.MaterialComponents.DayNight.NoActionBar
.
Ran into the same issue, setting app:backgroundTint="@null"
was what worked for me. See full solution here: https://github.com/material-components/material-components-android/issues/889#issuecomment-621194246
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With