Rounded corners on material button

前端 未结 7 719
粉色の甜心
粉色の甜心 2020-12-04 12:26

I\'m following the tips from questions like this to create a button style like suggested on Material Design.

However, I need to change the corner radius and

相关标签:
7条回答
  • 2020-12-04 13:00

    Try below code Create a drawable file called circular_button.xml and insert the below

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#008577" />
    <corners android:bottomRightRadius="100dp"
        android:bottomLeftRadius="100dp"
        android:topRightRadius="100dp"
        android:topLeftRadius="100dp"/>
    </shape>
    

    Then change the background of the button to this drawable file

     <Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/circle_button"
          android:text="Button"/>
    

    If you want a full circle button you can use the below drawable

    <?xml version="1.0" encoding="utf-8"?>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
    
        <solid
            android:color="#008577"/>
    
        <size
            android:width="120dp"
            android:height="120dp"/>
    </shape>
    
    0 讨论(0)
提交回复
热议问题