How to make the corners of a button round?

前端 未结 13 788
暖寄归人
暖寄归人 2020-11-22 16:36

I want to make the corners of a button round. Is there an easy way to achieve this in Android?

相关标签:
13条回答
  • 2020-11-22 17:40

    drawable folder

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="#FFFFFF"/>
        <corners android:radius="30dp"/>
        <stroke android:width="2dp" android:color="#999999"/>
    </shape>
    

    layout folder

    <Button
        android:id="@+id/button2"
        <!-- add style to avoid square background -->
        style="@style/Widget.AppCompat.Button.Borderless"
        android:background="@drawable/corner_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
    

    make sure add style to avoid square background

    0 讨论(0)
提交回复
热议问题