本文实例讲述了Android编程使用自定义shape实现shadow阴影效果的方法。分享给大家供大家参考,具体如下:
直接上xml文件, 并且附上相应的解析:
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
|
<? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < layer-list > <!-- 相当于padding --> < item android:left = "4dp" android:top = "4dp" > < shape > < solid android:color = "#ff58bb52" /> < corners android:radius = "30dip" /> </ shape > </ item > </ layer-list > </ item > < item > < layer-list > <!-- SHADOW LAYER --> < item android:left = "4dp" android:top = "4dp" > < shape > < solid android:color = "#66000000" /> < corners android:radius = "30dip" /> </ shape > </ item > <!-- CONTENT LAYER --> <!-- 相当于padding --> < item android:bottom = "4dp" android:right = "4dp" > < shape > < solid android:color = "#ff58bb52" /> < corners android:radius = "30dip" /> </ shape > </ item > </ layer-list > </ item > </ selector > |
希望本文所述对大家Android程序设计有所帮助。