Android控件陰影顏色調(diào)整示例
CardView在設(shè)置陰影的效果上來講,確實(shí)是蠻不錯(cuò)的。
但是涉及到變更陰影顏色這個(gè)需求,就不是太好操作。
然后就自己描邊畫了一個(gè)陰影效果,分享,支持任何顏色。
效果:

xml-selector
<?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>
關(guān)于描邊的大小什么的,都可以自己設(shè)置,顏色也一樣。都自己隨意。
使用起來也是非常簡單,
android:background="@drawable/lay_back"
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android逆向入門之常見Davlik字節(jié)碼解析
Dalvik是Google公司自己設(shè)計(jì)用于Android平臺的虛擬機(jī)。Dalvik虛擬機(jī)是Google等廠商合作開發(fā)的Android移動設(shè)備平臺的核心組成部分之一,本篇文章我們來詳細(xì)解釋常見Davlik字節(jié)碼2021-11-11
Android 自定義彈性ListView控件實(shí)例代碼(三種方法)
關(guān)于在Android中實(shí)現(xiàn)ListView的彈性效果,有很多不同的方法,網(wǎng)上一搜,也有很多,下面貼出在項(xiàng)目中經(jīng)常用到的兩種實(shí)現(xiàn)ListView彈性效果的方法(基本上拿來就可以用),需要的朋友參考下本段代碼2016-01-01
使用DrawerLayout組件實(shí)現(xiàn)側(cè)滑抽屜的功能
DrawerLayout組件同樣是V4包中的組件,也是直接繼承于ViewGroup類,所以說是一個(gè)容器類,下面通過本文給大家介紹使用DrawerLayout組件實(shí)現(xiàn)側(cè)滑抽屜的功能,感興趣的朋友一起看下吧2016-08-08
Android Studio 多層級 Module 對 aar 引用問題解決方法
這篇文章主要介紹了Android Studio 多層級 Module 對 aar 引用問題的解決方法,需要的朋友參考下2017-12-12
MPAndroidChart自定義圖表Chart的Attribute及Render繪制邏輯
這篇文章主要為大家介紹了MPAndroidChart自定義圖表Chart的Attribute及Render繪制邏輯,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12

