Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corner radius property missing on MaterialButton after update to Material 1.2.0

Here's my MaterialButton code:

<com.google.android.material.button.MaterialButton
    android:id="@+id/next_button"
    android:layout_width="224dp"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="68dp"
    android:layout_marginTop="510dp"
    android:layout_marginEnd="68dp"
    android:layout_marginBottom="68dp"
    android:background="@color/colorPrimary"
    android:minHeight="60dp"
    android:text="@string/onboarding_next_button"
    android:textColor="@android:color/white"
    app:cornerRadius="25dp" />

After update Material library from 1.1.0 to 1.2.0 the app:CornerRadius is ignored. I try with shape theme follow the Material documentation but the control still totally square

like image 495
Carlos Rguez M Avatar asked Dec 05 '25 04:12

Carlos Rguez M


1 Answers

Use app:backgroundTint instead of android:background

<com.google.android.material.button.MaterialButton
   app:backgroundTint="@color/colorPrimary"
   .../>

Starting with 1.2.0 it is possible to use the android:background in the MaterialButton. Using a custom android:background the default MaterialShapeDrawable is not used and some features like stroke, shapeappearance, corners radius, ripple are not set (since they are related to the MaterialShapeDrawable) and you have to provide them with your custom background

Since you are using a simple color as background just use app:backgroundTint.

enter image description here

like image 102
Gabriele Mariotti Avatar answered Dec 07 '25 18:12

Gabriele Mariotti