下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
【移動(dòng)應(yīng)用開(kāi)發(fā)技術(shù)】Android中怎么設(shè)置陰影效果
這篇文章將為大家詳細(xì)講解有關(guān)Android中怎么設(shè)置陰影效果,文章內(nèi)容質(zhì)量較高,因此在下分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。給控件設(shè)置陰影,會(huì)使得界面元素更好看一寫(xiě),google給我們提供了一個(gè)現(xiàn)成的控CardView,可以將CardView看做是FrameLayout在自身之上添加了圓角和陰影效果本文是使用給控件設(shè)置背景實(shí)現(xiàn)陰影在res/drawable下新建一個(gè)DrawableResourceFile使用layer-list圖層就是說(shuō)可以多個(gè)圖層一層一層蓋上去新建一個(gè)漸變的圖層item作為背景圖層,主要是gradient,shape是用來(lái)定義形狀的,corners設(shè)置角度,gradient定義該形狀里面為漸變色填充,startColor起始顏色,endColor結(jié)束顏色,angle表示方向角度。當(dāng)angle=0時(shí),漸變色是從左向右。然后逆時(shí)針?lè)较蜣D(zhuǎn),當(dāng)angle=90時(shí)為從下往上<item
>
<shape
android:shape="rectangle"
>
<gradient
android:angle="90"
android:endColor="#dad9d9"
android:startColor="#03a430"
/>
<corners
android:radius="10dp"
/>
</shape>
</item>新建一個(gè)圖層,作為頂層圖層,陰影實(shí)現(xiàn)的原理,就是頂層的小顯示一點(diǎn),露出一部分下面的圖層,這個(gè)就需要設(shè)置Item的left,top,right,bottom屬性,這幾個(gè)參數(shù)的設(shè)置就類(lèi)似于設(shè)置margin,這樣就可以出來(lái)陰影效果了,當(dāng)然為了效果,我的參數(shù)設(shè)置的有點(diǎn)夸張,只設(shè)置了右邊和下邊的陰影,solid設(shè)置填充,還有stroke設(shè)置邊框,設(shè)置了顏色,設(shè)置了寬度就可以看見(jiàn)邊框效果了<item
>
<shape
android:shape="rectangle"
>
<gradient
android:angle="90"
android:endColor="#dad9d9"
android:startColor="#03a430"
/>
<corners
android:radius="10dp"
/>
</shape>
</item>
<item
android:right="20dp"
android:bottom="40dp">
<shape
android:shape="rectangle"
>
<solid
android:color="#FFFFFF"/>
<corners
android:radius="10dp"
/>
</shape>
</item>頂層的圖層上,還是可以添加觸摸的變化效果,即手指觸碰到該控件時(shí),控件背景色變化<item
android:right="2dp"
android:bottom="6dp">
<selector>
<item
android:state_focused="false"
android:state_pressed="true"
>
<shape
android:shape="rectangle"
>
<solid
android:color="@color/E5"/>
<corners
android:radius="10dp"
/>
</shape>
</item>
<item>
<shape
android:shape="rectangle"
>
<solid
android:color="@color/white"/>
<corners
android:radius="10dp"
/>
</shape>
</item>
</selector>
</item>使用:android:background=”@drawable/你的陰影xml文件”<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/vcam_entry_border"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="@dimen/common_measure_10dp"
android:textColor="@color/black_100"
android:text="啦啦啦啦,我有陰影"/>
</LinearLayout>附:完整的陰影xml代碼<?xml
version="1.0"
encoding="utf-8"?>
<layer-list
xmlns:android="/apk/res/android"
>
<!--
陰影部分
最下面一層
-->
<item
>
<shape
android:shape="rectangle"
>
<gradient
android:angle="90"
android:endColor="#777777"
android:startColor="#C5C5C5"
/>
<corners
android:radius="10dp"
/>
</shape>
</item>
<!--
背景部分
-->
<!--
形象的表達(dá):bottom
left
...
類(lèi)似于設(shè)置
margin
-->
<item
android:right="2dp"
android:bottom="6dp">
<selector>
<item
android:state_focused="false"
android:state_pressed="true"
>
<shape
android:shape="rectangle"
>
<solid
android:color="@color/E5"/>
<corners
android:radius="10dp"
/>
</shape>
</item>
<item>
<shape
android:shape="rectangle"
>
<solid
android:color="@color/white"/>
<corners
android:
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 教學(xué)資源共享與交流活動(dòng)計(jì)劃
- 端蓋課程設(shè)計(jì)工藝路線(xiàn)
- 空間與表現(xiàn)課程設(shè)計(jì)論文
- 短視頻制作模板課程設(shè)計(jì)
- 哈工大模電課程設(shè)計(jì)
- 廣東省惠州博羅縣2024年數(shù)學(xué)三年級(jí)第一學(xué)期期末復(fù)習(xí)檢測(cè)模擬試題含解析
- 寧德市蕉城區(qū)2024年數(shù)學(xué)三上期末學(xué)業(yè)水平測(cè)試模擬試題含解析
- 2024-2025學(xué)年高中歷史專(zhuān)題5歐洲宗教改革測(cè)評(píng)含解析人民版選修1
- 2024年垣曲縣數(shù)學(xué)三上期末檢測(cè)模擬試題含解析
- 黑龍江省佳木斯市樺南縣2024-2025學(xué)年三年級(jí)數(shù)學(xué)第一學(xué)期期末復(fù)習(xí)檢測(cè)試題含解析
- 《基于項(xiàng)目式學(xué)習(xí)的初中語(yǔ)文散文教學(xué)探究(論文)》
- 普通高中通用重點(diǎn)技術(shù)學(xué)生設(shè)計(jì)作品圖文匯報(bào)材料
- 衛(wèi)生(醫(yī)學(xué))統(tǒng)計(jì)學(xué)課件
- DB33-T 2302-2020‘紅美人’柑橘設(shè)施綠色栽培技術(shù)規(guī)程
- 卡西歐登山表中文說(shuō)明書(shū)
- 六年級(jí)上冊(cè)美術(shù)課件-第2課 圖形的魔術(shù)組合 ▏人美版 (共14張PPT)
- 高會(huì)評(píng)審答辯
- 高中綜合實(shí)踐人教版高一全一冊(cè)綜合實(shí)踐-研究性學(xué)習(xí)手冊(cè)
- 歷屆挑戰(zhàn)杯全國(guó)大學(xué)生課外學(xué)術(shù)科技作品競(jìng)賽優(yōu)秀項(xiàng)目匯總
- 橋隧建筑物修理 課件 2.1橋隧建筑物修理組織
- 人教版二年級(jí)數(shù)學(xué)上冊(cè)2兩位數(shù)減兩位數(shù)-解決問(wèn)題課件
評(píng)論
0/150
提交評(píng)論