Android中shape的解析
生活随笔
收集整理的這篇文章主要介紹了
Android中shape的解析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<?xml version="1.0" encoding="utf-8"?>? <shape xmlns:android="http://schemas.android.com/apk/res/android" >? ?????<!-- 填充 --> ????<solid ????????android:color="#B2B2B2" ????????/>? ???????? ????<!-- 大小 --> ????<size ????????android:width="200dp" ????????android:height="50dp" ????????/>?? ????? ?????<!-- 漸變色 --> ????<gradient ????????android:startColor="#DBDCDD" ????????android:endColor="#B8B9BB" ????????android:centerColor="#ADADAF" ????????android:angle="270"? ????????/>? ?????? ????????? ????<!-- 描邊 --> ????<stroke ????????android:width="2dp" ????????android:color="#3D4148"? ????????/>?? ????????????? ????<!-- 圓角 --> ????<corners? ???????android:radius="5dp"? ????????/>? ?????? ????<padding ????????android:left="10dp" ????????android:top="10dp" ????????android:right="10dp" ????????android:bottom="10dp" ????????/>? ????? </shape>? ????? <!--?? ????? 1、? solid?? ?????描述:內部填充? ??????屬性???? android:color 填充顏色? ????? ????? 2、size?? ?????描述:size: 大小? ?????屬性:? ?????android:width?? 表示形狀的寬度? ?????android:height 表示形狀的高度? ????? 3、gradient? ?????????? ??????描述: 漸變色? ???????? ???????屬性:? ???????android:startColor? 起始顏色? ???????android:endColor??? 結束顏色? ???????android:angle?????? 漸變角度(PS:當angle=0時,漸變色是從左向右。 然后逆時針方向轉,當angle=90時為從下往上。angle必須為45的整數倍)? ???????android:type?????? 漸變類型(取值:linear、radial、sweep)? ????????????????????????????linear? 線性漸變,這是默認設置? ????????????????????????????radial? 放射性漸變,以開始色為中心。? ????????????????????????????sweep?? 掃描線式的漸變。? ???????android:centerColor? 漸變中間顏色,即開始顏色與結束顏色之間的顏色? ???????android:useLevel?? 如果要使用LevelListDrawable對象,就要設置為true。設置為true無漸變。false有漸變色? ???????android:gradientRadius? 漸變色半徑.當 android:type="radial" 時才使用。單獨使用 android:type="radial"會報錯。? ???????android:centerX??? 漸變中心X點坐標的相對位置? ???????android:centerY?? 漸變中心Y點坐標的相對位置? 4、stroke? ????? ????描述: stroke:描邊? 相當于html中的盒子模型的border? ????????????? ???屬性:? ????????android:width 描邊的寬度? ????????android:color 描邊的顏色? ????????android:dashWidth 表示描邊的樣式是虛線的寬度,? ?????????????????????????????????????????????????????????????值為0時,表示為實線。值大于0則為虛線。? ????????android:dashGap? 表示描邊為虛線時,虛線之間的間隔 即“ - - - - ”? ????????????? ?5、corners? ?????? ?????????描述: corners: 圓角? ?????????? ????????屬性:? ????????android:radius? 半徑? ????????android:topLeftRadius? 左上角半徑? ????????android:topRightRadius? 右上角半徑? ????????注意一下兩個屬性比較不同:? ????????android:bottomLeftRadius 右下角半徑? ????????android:bottomRightRadius 左下角半徑? ?6、padding? ??????????????? ??????????描述:內部邊距,即內容與邊的距離? ??????????????? ?????????屬性:? ????????android:left? 左內邊距? ????????android:top?? 上內邊距? ????????android:right? 右內邊距? ????????android:bottom 下內邊距? ?-->
總結
以上是生活随笔為你收集整理的Android中shape的解析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 国家标准委:瞄准重要领域和交叉领域加快工
- 下一篇: android sina oauth2.