Reputation: 21
This is how the button looks right now:
android:background= "@color/white"
does not change anything.
Code:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="Button"
android:background="@color/white"/>
Upvotes: 1
Views: 588
Reputation: 365018
Since you are using a color just use the app:backgroundTint
attribute:
<Button
app:backgroundTint="@color/white"/>
If you just need rounded corners with a stroke, you don't need a drawable.
For it use:
<com.google.android.material.button.MaterialButton
app:cornerRadius="16dp"
app:backgroundTint="@color/white"
app:strokeColor="@color/black"
android:textColor="@color/black"
app:strokeWidth="2dp" />
Upvotes: 1
Reputation: 286
Use app:backgroundTint="#FFFFFF"
If you want to use a selector, you will need to have android:background="@drawable/your_button_selector_id"
as the button background for the selector to work.
Selector:
<selector xmlns:android="schemas.android.com/apk/res/android">
<item android:drawable="@color/white" android:state_selected="true" />
<item android:drawable="@color/black" android:state_selected="false" /> </selector>
Upvotes: 1
Reputation: 30
Did you add value for white in your colors.xml
?
if not open colors.xml
and add
<color name="white">#FFFFFF</color>
Full Explanation here https://stackoverflow.com/a/2749027/7174681
Upvotes: 0