1. 这个很重要,由于android系统对应用的性能要求很高,在能用shape替换图片的时候就替换,这样可以为应用争取到更多的内存:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<? xml  version = "1.0"  encoding = "utf-8" ?>
< shape  xmlns:android = "http://schemas.android.com/apk/res/android"
     android:shape = "rectangle"  >
 
     <!-- rectangle | oval | line | ring -->
 
 
     <!-- <gradient  为shape指定渐变色 -->
     <!-- android:angle="int"  渐变色的角度值。0表示从左到右,90表示从下到上,必须是45的倍数,默认是0 -->
     <!-- android:centerX="float" 渐变色中心的X相对位置(0-1.0)。当android:type = "linear"时无效 -->
     <!-- android:centerY="float" 渐变色中心的Y相对位置(0-1.0)。当android:type = "linear"时无效 -->
     <!-- android:centerColor="color" 可选的颜色,出现在start和end颜色之间 -->
     <!-- android:endColor="color" end颜色 -->
     <!-- android:gradientRadius="float" 渐变色的半径。当android:type = "radial"时有效,而且必须设置 -->
     <!-- android:startColor="color" start 颜色 -->
     <!-- android:type="linear | radial | sweep" 渐变色的样式。有效值为:linear,线性渐变,默认值。radial,环形渐变,start的颜色是处于中间的颜色。sweep梯度渐变。sweep与radial不同的是,radial的颜色是从内往外渐变,sweep的颜色是从0到360渐变 -->
     <!-- android:useLevel="boolean" true:表示可以当做LevelListDrawable使用 -->
     <!-- /> -->
 
 
     <!-- <solid  填充shape的单一色 -->
     <!-- android:color="color" 这个颜色会应用到shape上/> -->
 
 
     <!-- <stroke -->
     <!-- android:width="dimension" 线的宽度 -->
     <!-- android:color="color" 线的颜色 -->
     <!-- android:dashGap="dimension" 线段与线段之间的空白距离。仅在android:dashWidth设定时有效。 -->
     <!-- android:dashWidth="dimension" 线段的长度。仅在android:dashGap设定时有效/> -->
 
 
     <!-- <padding dimension 内部View元素的边距 -->
     <!-- android:left="" -->
     <!-- android:top="" -->
     <!-- android:right="" -->
     <!-- android:bottom=""/> -->
 
 
     <!-- <corners 为shape创建圆角。当shape是一个rectangle时有效-->
     <!-- android:radius="dimension" 圆的半径,会被下面的特性覆盖 -->
     <!-- android:topLeftRadius="dimension" 左上圆角半径 -->
     <!-- android:topRightRadius="dimension" 右上圆角半径 -->
     <!-- android:bottomLeftRadius="dimension" 实际是右下圆角半径-->
     <!-- android:bottomRightRadius="dimension" 实际是左下圆角半径/> -->
 
     < size  />
 
</ shape >



















本文转自wauoen51CTO博客,原文链接: http://blog.51cto.com/7183397/1607090,如需转载请自行联系原作者