Android使用xml自定義圖片實例詳解
Android使用xml自定義圖片實例詳解
實現效果圖:

白色圓角圖片
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>
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關文章
Android自定義ViewGroup之FlowLayout(三)
這篇文章主要為大家詳細介紹了Android自定義ViewGroup之FlowLayout,常用于關鍵字標簽,搜索熱詞列表等功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-09-09
Android studio中生成引用.aar和.jar的方法詳解
這篇文章主要是講解.aar的生成與引用,文中的內容屬于完全基礎性概念,對剛學習使用Android studio的朋友們很有幫助,有需要的可以參考學習,下面來一起看看吧。2016-09-09
JSON中optString和getString方法的區(qū)別
optString方法會在對應的key中的值不存在的時候返回一個空字符串,但是getString會拋一個JSONException 。下面通過一段代碼給大家介紹JSON中optString和getString方法的區(qū)別,感興趣的朋友一起看看吧2017-07-07
Android Studio和Gradle使用不同位置JDK的問題解決
這篇文章主要介紹了Android Studio和Gradle使用不同位置JDK的問題解決,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-03-03

