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 自定義View的構(gòu)造函數(shù)詳細(xì)介紹
這篇文章主要介紹了Android 自定義View的構(gòu)造函數(shù)詳細(xì)介紹的相關(guān)資料,這里對構(gòu)造函數(shù)進(jìn)行了對比按需使用,需要的朋友可以參考下2016-12-12Android添加圖片到ListView或者RecyclerView顯示
這篇文章主要介紹了Android添加圖片到ListView或者RecyclerView顯示的相關(guān)資料,需要的朋友可以參考下2016-08-08Android開發(fā)實(shí)現(xiàn)讀取Assets下文件及文件寫入存儲卡的方法
這篇文章主要介紹了Android開發(fā)實(shí)現(xiàn)讀取Assets下文件及文件寫入存儲卡的方法,涉及Android文件與目錄的讀取、寫入、轉(zhuǎn)換等相關(guān)操作技巧,需要的朋友可以參考下2017-10-10Android開發(fā)中ProgressDialog簡單用法示例
這篇文章主要介紹了Android開發(fā)中ProgressDialog簡單用法,結(jié)合實(shí)例形式分析了Android使用ProgressDialog的進(jìn)度條顯示與關(guān)閉、更新等事件響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下2017-10-10Android 校驗(yàn)email是否合法實(shí)現(xiàn)代碼
這篇文章主要介紹了Android 校驗(yàn)email是否合法實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-01-01android教程之textview解析帶圖片的html示例
本文介紹的示例適用于android中需要解析帶圖片的htlm數(shù)據(jù),需要的朋友可以參考下2014-02-02