Android shape 绘制图形
Android 绘制图形可以使用shape也可以使用自定义控件的方式,这里我们说下shape的方式去实现。
在绘制图形之前,我们先来了解下shape的几个属性。
shape
/*
* 线行 圆形 矩形
/
android:shape="line"
android:shape="oval" android:shape="rectangle"
size
图形的大小
android:height="30dp"
android:width="30dp"
/>
stroke 边框属性
android:color= "#ff0000"
android:width= "4dp"
android:dashWidth= "10dp"
android:dashGap= "4dp"
/>
corners 属性
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"
/>
solid 绘制背景颜色属性
android:color="#F05F4C"
/>
gradient 颜色渐变属性
android:angle="0"
android:centerColor="#ff00ff"
android:endColor="#55ff00"
android:startColor="#ffcdcd">
padding 内边距属性
android:left="10dp"
android:right="10dp"
android:top="10dp"
android:bottom="10dp"
/>
以上是绘制图形常用的属性,现在我们绘制这张图片中的内容
android:layout_width="50dp"
android:layout_height="50dp"
android:text="12"
android:gravity="center"
android:textColor="#ffffff"
android:background="@drawable/text"
/>
shape绘制
android:shape="oval"
>
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"
/>
android:width="30dp"
android:height="30dp"
/>
android:width="1dp"
android:color="#ffffff" />
android:color="#F05F4C"
/>
以上就是关于Android shape 绘制图形的实例,本站对于Android View或组件重写的文章还很多,大家可以搜索参阅,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!