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
.
app:backgroundTint
attribute and a selector with the checked state and use the stylestyle="@style/Widget.MaterialComponents.Button.TextButton"
– Demonolater