界面邊框圓角的實現方式同樣是在res/drawable中定義一個XML文件,corners.xml的代碼如下:
1 |
<? xml
version = "1.0"
encoding = "utf-8" ?> |
2 |
< shape
xmlns:android = "http://schemas.android.com/apk/res/android" >
|
3 |
< solid
android:color = "#FF9900"
/> |
4 |
< corners
android:topLeftRadius = "10dp" |
5 |
android:topRightRadius = "10dp" |
6 |
android:bottomRightRadius = "10dp" |
7 |
android:bottomLeftRadius = "10dp" />
|
其中,solid的表示填充顏色,而corners則是表示圓角,注意的是這裏bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。
然後,在Activity中設置背景爲上面的xml,android:background="@drawable/corners",這樣即可實現邊框圓角。效果如下: