Search code examples
androidandroid-buttonandroid-themematerial-components-androidmaterial-components

app:cornerRadius is not working in android material design button


How to change corner radius of android material button. I tried setting corner radius but its not working.

<com.google.android.material.button.MaterialButton
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:background="@color/colorPrimary"
                android:text="Start"
                android:textColor="@android:color/white"
                android:textSize="18sp"
                app:cornerRadius="8dp" />

see the image attached


Solution

  • you need to set the style of Button like below

    and to use Material Design you need to add below dependencies in gradle.

    dependencies { implementation ‘com.google.android.material:material:1.1.0’ }
    

    XML

    <com.google.android.material.button.MaterialButton
    
       style="@style/Widget.MaterialComponents.Button"
       app:cornerRadius="8dp"/>