今天在看SDK文檔的時候發現了一個很是奇怪的布局檔案,裡邊是有關shape布局的xml檔案,霎時間不知道這是什麼東東,因此開始了狂搜SDK的開發指南,又從網上找了一大圈,終於是把shape的布局方式KO掉了,google真是強大啊,下面是sdk中的shape布局代碼,我們慢慢KO之
<?xml version="1.0" encoding="utf-8"?><br /><shape xmlns:android="http://schemas.android.com/apk/res/android"><br /> <solid android:color="#00000000"/><br /> <stroke android:width="1dp" color="#ff000000"/><br /> <padding android:left="1dp" android:top="1dp"<br /> android:right="1dp" android:bottom="1dp" /><br /></shape>
solid android:color=“” //使用這種顏色全部實心填充
stroke 描邊
android:width=“1dp” color=“#ff000000” 邊的顏色是#ff000000,寬度為1dp
padding 間隔 距離上下左右邊框的距離為1dp
在開發的過程中你還會用到
gradient 此屬性控制布局的漸層顏色
如<gradient android:startColor="#ff0000"
android:endColor="#ffffff" 設定漸層顏色,從#ff0000漸層到#ffffff
android:angle="90" 設定漸層角度必須為45度得整數倍
android:type="linear" 將漸層模式設定成線性模式
>
corners 屬性設定邊角角度
<corners
android:topRightRadius="20dp" 右上方
android:bottomLeftRadius="20dp" 右下角
android:topLeftRadius="1dp" 左上方
android:bottomRightRadius="0dp" 左下角
>