Android零碎知識點(6)——設置Button爲圓形按鈕

在res/drawable文件夾下創建一個button_shape.xml文件,代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <corners android:radius="0dp" />   <!-- 設置圓角弧度 -->
    <solid android:color="#FF7001" />   <!-- 設置背景顏色 -->
    <size
        android:width="40dp"
        android:height="40dp" />
    <stroke
        android:width="0dp"
        android:color="#fff" />
</shape>

接着就是在Button控件中通過android:background進行引用

android:background="@drawable/button_shape"

效果如下:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章