詳解android shape的使用總結(jié)
shape用于設(shè)定形狀,可以在selector,layout等里面使用,有6個(gè)子標(biāo)簽,各屬性如下:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 圓角 --> <corners android:radius="9dp" android:topLeftRadius="2dp" android:topRightRadius="2dp" android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/><!-- 設(shè)置圓角半徑 --> <!-- 漸變 --> <gradient android:startColor="@android:color/white" android:centerColor="@android:color/black" android:endColor="@android:color/black" android:useLevel="true" android:angle="45" android:type="radial" android:centerX="0" android:centerY="0" android:gradientRadius="90"/> <!-- 間隔 --> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp"/><!-- 各方向的間隔 --> <!-- 大小 --> <size android:width="50dp" android:height="50dp"/><!-- 寬度和高度 --> <!-- 填充 --> <solid android:color="@android:color/white"/><!-- 填充的顏色 --> <!-- 描邊 --> <stroke android:width="2dp" android:color="@android:color/black" android:dashWidth="1dp" android:dashGap="2dp"/> </shape>
填充:設(shè)置填充的顏色
間隔:設(shè)置四個(gè)方向上的間隔
大?。涸O(shè)置大小
圓角:同時(shí)設(shè)置五個(gè)屬性,則Radius屬性無(wú)效
- android:Radius="20dp" 設(shè)置四個(gè)角的半徑
- android:topLeftRadius="20dp" 設(shè)置左上角的半徑
- android:topRightRadius="20dp" 設(shè)置右上角的半徑
- android:bottomLeftRadius="20dp" 設(shè)置右下角的半徑
- android:bottomRightRadius="20dp" 設(shè)置左下角的半徑
描邊:dashWidth和dashGap屬性,只要其中一個(gè)設(shè)置為0dp,則邊框?yàn)閷?shí)現(xiàn)邊框
- android:width="20dp" 設(shè)置邊邊的寬度
- android:color="@android:color/black" 設(shè)置邊邊的顏色
- android:dashWidth="2dp" 設(shè)置虛線的寬度
- android:dashGap="20dp" 設(shè)置虛線的間隔寬度
漸變:當(dāng)設(shè)置填充顏色后,無(wú)漸變效果。angle的值必須是45的倍數(shù)(包括0),僅在type="linear"有效,不然會(huì)報(bào)錯(cuò)。android:useLevel 這個(gè)屬性不知道有什么用。
angle對(duì)應(yīng)值的起點(diǎn)如圖:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android編程使用自定義shape實(shí)現(xiàn)shadow陰影效果的方法
- Android自定義shape的使用示例
- Android控件系列之Shape使用方法
- Android中的Shape和Selector的結(jié)合使用實(shí)例
- Android中shape定義控件的使用
- Android shape和selector 結(jié)合使用實(shí)例代碼
- Android開(kāi)發(fā)教程之shape和selector的結(jié)合使用
- Android中drawable使用Shape資源
- Android使用Shape實(shí)現(xiàn)ProgressBar樣式實(shí)例
- Android利用shape實(shí)現(xiàn)各種簡(jiǎn)單的形狀
相關(guān)文章
Android listview ExpandableListView實(shí)現(xiàn)多選,單選,全選,edittext實(shí)現(xiàn)批量輸入
這篇文章主要介紹了Android listview ExpandableListView實(shí)現(xiàn)多選,單選,全選,edittext實(shí)現(xiàn)批量輸入的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-01-01Android編程實(shí)現(xiàn)網(wǎng)絡(luò)圖片查看器和網(wǎng)頁(yè)源碼查看器實(shí)例
這篇文章主要介紹了Android編程實(shí)現(xiàn)網(wǎng)絡(luò)圖片查看器和網(wǎng)頁(yè)源碼查看器,結(jié)合實(shí)例形式分析了Android針對(duì)網(wǎng)絡(luò)圖片及網(wǎng)頁(yè)的相關(guān)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-01-01Android數(shù)據(jù)持久化之SQLite數(shù)據(jù)庫(kù)用法分析
這篇文章主要介紹了Android數(shù)據(jù)持久化之SQLite數(shù)據(jù)庫(kù)用法,結(jié)合實(shí)例形式分析了SQLite概念、功能、相關(guān)操作類與使用技巧,需要的朋友可以參考下2017-05-05android圖像繪制(四)自定義一個(gè)SurfaceView控件
自定義控件(類似按鈕等)的使用,自定義一個(gè)SurfaceView。如某一塊的動(dòng)態(tài)圖(自定義相應(yīng)),或者類似UC瀏覽器下面的工具欄,感興趣的朋友可以了解下2013-01-01Android中實(shí)現(xiàn)用命令行同步網(wǎng)絡(luò)時(shí)間
這篇文章主要介紹了Android中實(shí)現(xiàn)用命令行同步網(wǎng)絡(luò)時(shí)間,本文講解使用BusyBox實(shí)現(xiàn)同步網(wǎng)絡(luò)時(shí)間,并給出了詳細(xì)操作步驟,需要的朋友可以參考下2015-07-07安卓GET與POST網(wǎng)絡(luò)請(qǐng)求的三種方式
今天小編就為大家分享一篇關(guān)于安卓GET與POST網(wǎng)絡(luò)請(qǐng)求的三種方式,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-12-12