Android控件陰影顏色調(diào)整示例
CardView在設(shè)置陰影的效果上來講,確實是蠻不錯的。
但是涉及到變更陰影顏色這個需求,就不是太好操作。
然后就自己描邊畫了一個陰影效果,分享,支持任何顏色。
效果:
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 SwipereFreshLayout下拉刷新
這篇文章主要介紹了Android SwipereFreshLayout下拉刷新的相關(guān)資料,需要的朋友可以參考下2017-06-06Android重寫TextView實現(xiàn)文字整齊排版的方法(附demo源碼下載)
這篇文章主要介紹了Android重寫TextView實現(xiàn)文字整齊排版的方法,結(jié)合實例形式分析了Android重寫TextView實現(xiàn)文字整齊排版的相關(guān)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-02-02Flutter Http網(wǎng)絡(luò)請求實現(xiàn)詳解
這篇文章主要介紹了Flutter Http網(wǎng)絡(luò)請求實現(xiàn)詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04關(guān)于Android CountDownTimer的使用及注意事項
這篇文章主要介紹了關(guān)于Android CountDownTimer的使用及注意事項,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-11-11Android自定義帶增長動畫和點擊彈窗提示效果的柱狀圖DEMO
這篇文章主要介紹了Android自定義帶增長動畫和點擊彈窗提示效果的柱狀圖的相關(guān)資料,非常不錯具有一定的參考借鑒價值,需要的朋友可以參考下2016-11-11Android調(diào)用系統(tǒng)照相機(jī)拍照與攝像的方法
這篇文章主要為大家詳細(xì)介紹了Android如何調(diào)用系統(tǒng)現(xiàn)有的照相機(jī)拍照與攝像,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-04-04深入淺析Android手機(jī)衛(wèi)士保存密碼時進(jìn)行md5加密
一般的手機(jī)沒有root權(quán)限,進(jìn)不去data/data目錄,當(dāng)手機(jī)刷機(jī)了后,擁有root權(quán)限,就可以進(jìn)入data/data目錄,查看我們保存的密碼文件,因此我們需要對存入的密碼進(jìn)行MD5加密,接下來通過本文給大家介紹Android手機(jī)衛(wèi)士保存密碼時進(jìn)行md5加密,需要的朋友一起學(xué)習(xí)吧2016-04-04Android TextView自定義數(shù)字滾動動畫
這篇文章主要為大家詳細(xì)介紹了Android TextView自定義數(shù)字滾動動畫,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04Android使用Canvas?2D實現(xiàn)循環(huán)菜單效果
循環(huán)菜單有很多種自定義方式,我們可以利用ViewPager或者RecyclerView?+?CarouselLayoutManager?或者RecyclerView?+?PageSnapHelper來實現(xiàn)這種效果,今天我們使用Canvas?2D來實現(xiàn)這種效果,感興趣的朋友可以參考下2024-01-01