这篇文章给大家介绍如何在Android中使用shape 绘制图形,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
shape
/*
* 线行 圆形 矩形
/
android:shape="line"
android:shape="oval" android:shape="rectangle"
size
图形的大小
<size
android:height="30dp"
android:width="30dp"
/>
stroke 边框属性
<!--
边框的颜色
边框的宽度
虚线的长度
虚线之间的间隙
-->
<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 内边距属性
<!-- 内边距 -->
<padding
android:left="10dp"
android:right="10dp"
android:top="10dp"
android:bottom="10dp"
/>
以上是绘制图形常用的属性,现在我们绘制这张图片中的内容
<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>
关于如何在Android中使用shape 绘制图形就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。