Android使用xml自定義圖片實(shí)例詳解
Android使用xml自定義圖片實(shí)例詳解
實(shí)現(xiàn)效果圖:

白色圓角圖片
bg_round_rectangle_white.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 填充 --> <solid android:color="#FFFFFF" /> <!-- 圓角 --> <corners android:radius="2dp"/> <!-- 描邊 --> <stroke android:width="1dp" android:color="#D5D5D5"/> </shape>
白色圓角虛線框
bg_round_rectangle_white_dash.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 填充 --> <solid android:color="#FFFFFF" /> <!-- 圓角 --> <corners android:radius="2dp"/> <!-- 虛線描邊 --> <stroke android:width="1dp" android:color="#DD4041" android:dashWidth="1dp" android:dashGap="2dp"/> </shape>
紅色圓角圖片
bg_round_rectangle_red.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 填充 --> <solid android:color="#F15C5D" /> <!-- 圓角 --> <corners android:radius="2dp"/> <!-- 描邊 --> <stroke android:width="1dp" android:color="#D42D2E"/> </shape>
綠色圓角圖片
bg_round_rectangle_green.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- 填充 --> <solid android:color="#88C14E" /> <!-- 圓角 --> <corners android:radius="2dp"/> <!-- 描邊 --> <stroke android:width="1dp" android:color="#6FA13C"/> </shape>
正三角形圖片
triangle_white_arrow_up.xml
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="80%"> <shape android:shape="rectangle"> <solid android:color="#000000"/> </shape> </rotate>
倒立正三角形圖片
triangle_white_arrow_down.xml
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="45" android:toDegrees="45" android:pivotX="135%" android:pivotY="15%"> <shape android:shape="rectangle"> <solid android:color="#000000"/> </shape> </rotate>
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android編程實(shí)現(xiàn)wifi掃描及連接的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)wifi掃描及連接的方法,涉及Android網(wǎng)絡(luò)操作掃描、查找、連接、線程等相關(guān)操作技巧,需要的朋友可以參考下2018-02-02
Android數(shù)據(jù)加密之Rsa加密的簡單實(shí)現(xiàn)
下面小編就為大家?guī)硪黄狝ndroid數(shù)據(jù)加密之Rsa加密的簡單實(shí)現(xiàn)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-10
Android?數(shù)據(jù)結(jié)構(gòu)全面總結(jié)分析
這篇文章主要為大家介紹了Android?數(shù)據(jù)結(jié)構(gòu)全面總結(jié)分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
Android自定義ViewGroup之FlowLayout(三)
這篇文章主要為大家詳細(xì)介紹了Android自定義ViewGroup之FlowLayout,常用于關(guān)鍵字標(biāo)簽,搜索熱詞列表等功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-09-09
Android studio中生成引用.aar和.jar的方法詳解
這篇文章主要是講解.aar的生成與引用,文中的內(nèi)容屬于完全基礎(chǔ)性概念,對剛學(xué)習(xí)使用Android studio的朋友們很有幫助,有需要的可以參考學(xué)習(xí),下面來一起看看吧。2016-09-09
Android實(shí)現(xiàn)購物車及其他功能的角標(biāo)
本文主要介紹了Android實(shí)現(xiàn)購物車及其他功能的角標(biāo)的相關(guān)知識。具有很好的參考價值。下面跟著小編一起來看下吧2017-04-04
JSON中optString和getString方法的區(qū)別
optString方法會在對應(yīng)的key中的值不存在的時候返回一個空字符串,但是getString會拋一個JSONException 。下面通過一段代碼給大家介紹JSON中optString和getString方法的區(qū)別,感興趣的朋友一起看看吧2017-07-07
Android Studio和Gradle使用不同位置JDK的問題解決
這篇文章主要介紹了Android Studio和Gradle使用不同位置JDK的問題解決,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03

