Android shape 繪制圖形的實(shí)例詳解
Android shape 繪制圖形
Android 繪制圖形可以使用shape也可以使用自定義控件的方式,這里我們說(shuō)下shape的方式去實(shí)現(xiàn)。
在繪制圖形之前,我們先來(lái)了解下shape的幾個(gè)屬性。
shape
/* * 線行 圓形 矩形 / android:shape="line" android:shape="oval" android:shape="rectangle"
size
圖形的大小
<size
android:height="30dp"
android:width="30dp"
/>
stroke 邊框?qū)傩?/strong>
<!-- 邊框的顏色 邊框的寬度 虛線的長(zhǎng)度 虛線之間的間隙 --> <stroke android:color= "#ff0000" android:width= "4dp" android:dashWidth= "10dp" android:dashGap= "4dp" />
corners 屬性
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"
/>
solid 繪制背景顏色屬性
<solid
android:color="#F05F4C"
/>
gradient 顏色漸變屬性
<gradient
android:angle="0"
android:centerColor="#ff00ff"
android:endColor="#55ff00"
android:startColor="#ffcdcd"></gradient>
padding 內(nèi)邊距屬性
<!-- 內(nèi)邊距 -->
<padding
android:left="10dp"
android:right="10dp"
android:top="10dp"
android:bottom="10dp"
/>
以上是繪制圖形常用的屬性,現(xiàn)在我們繪制這張圖片中的內(nèi)容

<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:text="12"
android:gravity="center"
android:textColor="#ffffff"
android:background="@drawable/text"
/>
shape繪制
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"
/>
<size
android:width="30dp"
android:height="30dp"
/>
<stroke
android:width="1dp"
android:color="#ffffff" />
<solid
android:color="#F05F4C"
/>
</shape>
以上就是關(guān)于Android shape 繪制圖形的實(shí)例,本站對(duì)于Android View或組件重寫(xiě)的文章還很多,大家可以搜索參閱,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
設(shè)置界面開(kāi)發(fā)Preference Library數(shù)據(jù)重建機(jī)制詳解
這篇文章主要為大家介紹了設(shè)置界面開(kāi)發(fā)利器Preference Library數(shù)據(jù)重建機(jī)制詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10
Android手機(jī)拍照或選取圖庫(kù)圖片作為頭像
這篇文章主要介紹了Android手機(jī)拍照或選取圖庫(kù)圖片作為頭像的相關(guān)資料,需要的朋友可以參考下2015-06-06
Android筆記設(shè)計(jì)范例之日記APP實(shí)現(xiàn)全流程
這篇文章主要介紹了Android筆記設(shè)計(jì)范例之日記APP實(shí)現(xiàn)全流程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧2023-01-01
Android實(shí)現(xiàn)帶頭像的用戶注冊(cè)頁(yè)面
這篇文章主要介紹了Android實(shí)現(xiàn)帶頭像的用戶注冊(cè)頁(yè)面的相關(guān)資料,介紹的非常詳細(xì),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06
TextView長(zhǎng)按復(fù)制的實(shí)現(xiàn)方法(總結(jié))
下面小編就為大家?guī)?lái)一篇TextView長(zhǎng)按復(fù)制的實(shí)現(xiàn)方法(總結(jié))。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-04-04
Android簡(jiǎn)單實(shí)現(xiàn)自定義彈框(PopupWindow)
本文主要介紹了Android利用PopupWindow實(shí)現(xiàn)自定義彈框的相關(guān)知識(shí)。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-04-04
Android實(shí)現(xiàn)下載進(jìn)度條效果
vivo商店在下載應(yīng)用的時(shí)候,底部有一個(gè)圓角矩形的下載進(jìn)度條,中間有一個(gè)進(jìn)度文字,而且進(jìn)度和文字交匯的時(shí)候,交匯部分的文字會(huì)從藍(lán)色邊為白色,會(huì)有一種一半白色字,一半藍(lán)色字的效果。本文將仿照該樣式實(shí)現(xiàn)一個(gè)2021-06-06

