android 使用shape自定義圓角矩形
今天專案中需要用到圓角矩形邊框,就自己定義了一個,雖然很簡單,但也記錄一下。
在eclipse中新建shape檔案步驟:
1.選中res下面的drawable目錄,點選滑鼠右鍵New->Android Xml File。
2.Resource Type選中Drawable,Root Element選中shape。
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 填充的顏色 -->
<!-- <solid android:color="#04AEC7" />-->
<!-- 設定邊框寬度 -->
<stroke android:width="1dp" android:color="#999999"/>
<!-- 四個角的弧度 -->
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<!-- padding:TextView裡面的文字與TextView邊界的間隔 -->
<padding
android:bottom="5dp"
android:left="2dp"
android:right="2dp"
android:top="5dp" />
<!-- <size android:width="100dp" android:height="45dp"/> -->
</shape>