安卓中shape的畫法

2021-07-26 13:50:39 字數 995 閱讀 5562

首先在res/drawable資料夾下,新建乙個xml檔案:

基本屬性(corners、gradient

漸變色、padding、size、solid、stroke

描邊)

<?xmlversion="1.0" encoding="utf-8"?>

//shape

的形狀,預設為矩形

可以設定為矩形(rectangle)、橢圓形(oval)、線性形狀(line)、環形(ring)

//定義圓角

所有圓角半徑android:topleftradius="dimension"             //左上角的圓角半徑

android:bottomrightradius="dimension"/>      //右下角的圓角半徑

//solid

用以指定內部填充色

//gradient

用以定義漸變色

//共有3中漸變型別,線性漸變(預設)/放射漸變/掃瞄式漸變

android:angle="integer"    

//漸變角度,必須為45的倍數,0為從左到右,90為從上到下

android:centerx="float"  />

//漸變中心x的相當位置,範圍為0~1                 /

描邊的寬度

android:color="color" />                  //描邊的顏色

android:width="50dp"                    //大小

android:height="50dp" />                   //oval寬高相等就是圓

android:innerradius         尺寸,內環的半徑

android:thickness          尺寸,環的厚度

android:innerradiusratio   浮點型,以環的寬度比率來表示內環的半徑

shape/>

安卓shape屬性詳解

corners 屬性設定控制項四個角的弧度 stroke width 設定邊框的寬度 color 設定顏色 solid 設定背景色 gradient 是shape的顏色漸變屬性 android angle 代表漸變顏色的角度,也就是從 開始漸變 startcolor 顏色漸變的開始顏色 endcol...

安卓互動之shape的學習

為了實現透明邊框的圓角矩形的按鈕背景,所以了解了一下shape的各項屬性 1.shape中常用的屬性如下 有四種屬性值,矩形,橢圓,線,圓環 android centerx integer 0 1,漸變的x軸起始位置 android centery integer 0 1,漸變的y軸起始位置 and...

安卓中sharedperference的用法

引數 sharedperference 使用步驟 1.獲取到 sp this.getsharedpreferences config 0 2.獲取編輯器 editor editor sp.edit 3.editor.putstring key,value putint putdouble 4.edi...