android shape实现阴影或模糊边效果

1.实现阴影或模糊边效果方式:

 

android shape实现阴影或模糊边效果_第1张图片

 

2.通过shape来实现,具体是通过layer-list 多层叠放的方式实现的

 1 "1.0" encoding="utf-8"?>
 2 "http://schemas.android.com/apk/res/android">
 3     
 4     
 5         "rectangle">
 6             <padding
 7                 android:bottom="2dp"
 8                 android:left="2dp"
 9                 android:right="2dp"
10                 android:top="2dp" />
11             "#00CCCCCC" />
12             "8dp" />
13         
14     
15     
16         "rectangle">
17             <padding
18                 android:bottom="2dp"
19                 android:left="2dp"
20                 android:right="2dp"
21                 android:top="2dp" />
22             "#10CCCCCC" />
23             "8dp" />
24         
25     
26     
27         "rectangle">
28             <padding
29                 android:bottom="2dp"
30                 android:left="2dp"
31                 android:right="2dp"
32                 android:top="2dp" />
33             "#20CCCCCC" />
34             "8dp" />
35         
36     
37     
38         "rectangle">
39             <padding
40                 android:bottom="2dp"
41                 android:left="2dp"
42                 android:right="2dp"
43                 android:top="2dp" />
44             "#30CCCCCC" />
45             "8dp" />
46         
47     
48     
49         "rectangle">
50             <padding
51                 android:bottom="2dp"
52                 android:left="2dp"
53                 android:right="2dp"
54                 android:top="2dp" />
55             "#50CCCCCC" />
56             "8dp" />
57         
58     
59 
60     
61     
62         "rectangle"
63             android:useLevel="false">
64             
65             "#ffffff" />
66             "10dp" />
67             "10dp"
68                 android:right="10dp"
69                 android:top="10dp"
70                 android:bottom="10dp"/>
71         
72     
73 

使用:

android:background="@drawable/layer_white_bg"

 顶部缩放了:android:top=2*5=10dp

你可能感兴趣的