您好,登錄后才能下訂單哦!
這篇文章給大家介紹如何在Android中使用shape 繪制圖形,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
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 繪制圖形就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。