一、写在前面的:
TextView、Button、EditText、ProgressBar、Toast、Checkbox等控件的样式背景,都可以用shape来实现,可以优化资源的使用,在一个项目中,个人觉得各种资源统一管理起来最好,公用一套,方便后期管理,不管以后是你自己管理,还是有后来者接手,都能大大提高工作效率,相信你也不想接手一个写的很乱的项目,都说“见字如见人”,作为一个程序员来说,咱们的代码就是咱们的字,最起码得让人觉得“嗯!这人还不错”。
闲话不多说了,下面记载一下个人总结的shape用法
二、shape属性:
先来了解一下shape的各个属性
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- rectangle:矩形、圆角矩形、弧形等
oval:圆、椭圆
line:线、实线、虚线
ring:环形 -->
<corners <!-- 圆角 只适用于rectangle类型-->
android:radius="integer" <!-- 圆角半径 -->
android:bottomLeftRadius="integer"
android:bottomRightRadius="integer"
android:topLeftRadius="integer"
android:topRightRadius="integer" />
<gradient <!-- 渐变色 -->
<!-- 渐变的角度,线性渐变时才有效,必须是45的倍数 -->
android:angle="integer"
&l