先上,: 設定邊框圓角可以在drawable-mdpi目錄裡定義一個xml檔案,如corners_bg.xml,具體代碼如下: [html] <span style="font-size:14px;"><?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#000000" /> <corners android:topLeftRadius="10dp" android:topRightRadius="10dp" android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/> </shape></span> 解釋如下:solid的表示填充顏色,這裡用的是黑色;而corners則是表示圓角,注意的是這裡bottomRightRadius是左下角而不是右下角,bottomLeftRadius右下角。 要想使用上面的圓角邊框檔案,即在布局檔案中加入即可,如在main.xml檔案中使用: [html] <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF"> <RelativeLayout android:id="@+id/re" android:layout_width="fill_parent" android:layout_height="150dip" android:padding="15dip" android:layout_margin="15dip" android:background="@drawable/corners_bg"> </RelativeLayout> </LinearLayout>