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)文章
Android制作一個(gè)錨點(diǎn)定位的ScrollView
這篇文章主要介紹了Android制作一個(gè)錨點(diǎn)定位的ScrollView,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-04-04
Handler實(shí)現(xiàn)線程之間的通信下載文件動(dòng)態(tài)更新進(jìn)度條
每一個(gè)線程對(duì)應(yīng)一個(gè)消息隊(duì)列MessageQueue,實(shí)現(xiàn)線程之間的通信,可通過(guò)Handler對(duì)象將數(shù)據(jù)裝進(jìn)Message中,再將消息加入消息隊(duì)列,而后線程會(huì)依次處理消息隊(duì)列中的消息。這篇文章主要介紹了Handler實(shí)現(xiàn)線程之間的通信下載文件動(dòng)態(tài)更新進(jìn)度條,需要的朋友可以參考下2017-08-08
Android 日常開(kāi)發(fā)總結(jié)的60條技術(shù)經(jīng)驗(yàn)
這篇文章主要介紹了Android日常開(kāi)發(fā)總結(jié)的技術(shù)經(jīng)驗(yàn)60條,需要的朋友可以參考下2016-03-03
android service實(shí)現(xiàn)循環(huán)定時(shí)提醒功能
這篇文章主要為大家詳細(xì)介紹了android service實(shí)現(xiàn)循環(huán)定時(shí)提醒功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-01-01
Android二維碼開(kāi)發(fā)學(xué)習(xí)教程
這篇文章主要為大家分享了Android二維碼開(kāi)發(fā)學(xué)習(xí)教程,感興趣的小伙伴們可以參考一下2016-07-07
Android實(shí)現(xiàn)的仿淘寶購(gòu)物車demo示例
這篇文章主要介紹了Android實(shí)現(xiàn)的仿淘寶購(gòu)物車demo示例,結(jié)合實(shí)例形式分析了Android購(gòu)物車的功能、布局及邏輯實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-07-07
Android的HTTP類庫(kù)Volley入門學(xué)習(xí)教程
這篇文章主要介紹了Android應(yīng)用開(kāi)發(fā)框架Volley的入門學(xué)習(xí)教程,Volley適合于輕量級(jí)的通信功能開(kāi)發(fā),善于處理JSON對(duì)象,需要的朋友可以參考下2016-02-02
Flutter中跨組件數(shù)據(jù)傳遞的方法總結(jié)
Flutter中的數(shù)據(jù)傳遞一般包括:父->子,子->父,父->父,也就是說(shuō)嵌套時(shí)的傳遞以及跨頁(yè)面的傳遞,本文整理了三種我們通常使用的方法,需要的可以參考一下2023-06-06

