在drawable檔案夾下建立btn_shape.xml檔案:


先解釋一下上面的代碼:
1.shape用于定義形狀,有四種形狀(矩形rectangle| 橢圓oval | 直線line | 圓形ring)。
2.solid用于設定填充形狀的顔色。
3.corners用于建立圓角(隻用于形狀是矩形)。
topleftradius、toprightradius、bottomleftradius、bottomrightradius分别設定左上,右上,左下,右下圓角的半徑。
使用方法:
android:background="@drawable/btn_shape"
效果圖:
原文位址:http://www.cnblogs.com/johntsai/p/4307462.html