abstrait:頁(yè)面上有時(shí)會(huì)用到背景為空心圓角矩形的Button,可以通過(guò)xml繪制出來(lái)。drawrable文件夾下bg_red_hollow_rectangle.xml<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schema
頁(yè)面上有時(shí)會(huì)用到背景為空心圓角矩形的Button,可以通過(guò)xml繪制出來(lái)。
drawrable文件夾下bg_red_hollow_rectangle.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/transparent"/> <stroke android:width="1dp" android:color="#ce1818" /> <corners android:radius="@dimen/public_space_value_5"/> </shape>
shape:圖形,rectangle為矩形;
stoke:描邊
solid:填充
corners:圓角
在layout中的使用
<Button android:layout_width="80dp" android:layout_height="50dp" android:background="@drawable/bg_red_hollow_rectangle" android:gravity="center" android:text="分享" />
效果圖如下: