我是靠谱客的博主 稳重书本,这篇文章主要介绍Android控件阴影颜色调整示例,现在分享给大家,希望可以做个参考。

CardView在设置阴影的效果上来讲,确实是蛮不错的。

但是涉及到变更阴影颜色这个需求,就不是太好操作。

然后就自己描边画了一个阴影效果,分享,支持任何颜色。

效果:

xml-selector

复制代码
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="true"> <layer-list> <item android:right="1dp" android:top="2dp"> <layer-list> <item> <shape android:shape="rectangle"> <solid android:color="#15cbf2e0" /> <padding android:bottom="6px" android:left="6px" android:right="6px" android:top="6px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#16cbf2e0" /> <padding android:bottom="4px" android:left="4px" android:right="4px" android:top="4px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#17cbf2e0" /> <padding android:bottom="2px" android:left="2px" android:right="2px" android:top="2px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#18cbf2e0" /> <padding android:bottom="3px" android:left="2px" android:right="2px" android:top="1px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#19cbf2e0" /> <padding android:bottom="3px" android:left="2px" android:right="2px" android:top="1px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#20cbf2e0" /> <padding android:bottom="3px" android:left="2px" android:right="2px" android:top="1px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#21cbf2e0" /> <padding android:bottom="3px" android:left="2px" android:right="2px" android:top="1px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#22cbf2e0" /> <padding android:bottom="3px" android:left="2px" android:right="2px" android:top="1px" /> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="#23cbf2e0" /> <padding android:bottom="3px" android:left="2px" android:right="2px" android:top="1px" /> </shape> </item> </layer-list> </item> <item> <shape android:shape="rectangle"> <solid android:color="@color/white" /> </shape> </item> </layer-list> </item> </selector>

关于描边的大小什么的,都可以自己设置,颜色也一样。都自己随意。

使用起来也是非常简单,

复制代码
1
android:background="@drawable/lay_back"

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持靠谱客。

最后

以上就是稳重书本最近收集整理的关于Android控件阴影颜色调整示例的全部内容,更多相关Android控件阴影颜色调整示例内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(134)

评论列表共有 0 条评论

立即
投稿
返回
顶部