javaandroidmaterialbutton

MaterialButton disappears on setting android:background


When I assign a button to android:background="@color/white", the button disappears behind the round corners, I know, it's related to android:background="@color/white", how do I solve this problem? how to change color and make rounded corners?

Theme

<resources xmlns:tools="schemas.android.com/tools" 
    xmlns:app="schemas.android.com/apk/res-auto"> 
    <!-- Base application theme. --> 
    <style name="Theme.SnapChat"
        parent="Theme.MaterialComponents.DayNight.DarkActionBar"> 

        <item name="android:background">@color/white</item> 
        <item name="android:text">@string/button1</item>
        <item name="android:textSize">14sp</item>
        <item name="android:gravity">center|center_vertical</item>
        <item name="strokeColor">@color/yellow</item>

    </style>
</resources>

Code

<com.google.android.material.button.MaterialButton
    android:id="@+id/button1"
    android:layout_width="128dp"
    android:layout_height="36dp"
    android:layout_alignParentStart="true" 
    android:layout_alignParentBottom="true"
    android:layout_marginStart="66dp"
    android:layout_marginBottom="45dp"
    android:style="@style/Theme.SnapChat"
    app:cornerRadius="100dp"
/>

Solution

  • enter image description here

    You should use

    app:backgroundTint="@color/white"