Search code examples
androidmaterial-designandroid-buttonmaterial-componentsmaterial-components-android

app:cornerRadius doesn't work for MaterialButton


<com.google.android.material.button.MaterialButton
            android:id="@+id/button_tour"
            app:cornerRadius="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="30dp"
            android:layout_gravity="center_horizontal"
            android:text="Take a tour"/>

I added a material button in my android project, when i try to set round corner using app:cornerRadius, i find it doesn't work at all.


Solution

  • Just use material theme .change parent of AppTheme in styles to some material theme likeTheme.MaterialComponents.Light.NoActionBar.because material components require a material theme.

     <style name="AppTheme.Clinic" parent="Theme.MaterialComponents.Light.NoActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
    </style>