shape标签
1. 首先,先在res/drawable文件夹下新建button_shape xml文件,要在res目录下创建
2. shape的子标签(corners、gradient、padding、size、solid、stroke)
corners属性
<corners //定义圆角
android:radius="dimension" //全部的圆角半径
android:topLeftRadius="dimension" //左上角的圆角半径
android:topRightRadius="dimension" //右上角的圆角半径
android:bottomLeftRadius="dimension" //左下角的圆角半径
android:bottomRightRadius="dimension" /> //右下角的圆角半径
corners是用来定义圆角的,但是radius与其他四个角的属性不能同时使用
那定义完圆角后要怎么使用呢?
是要使用android:background属性即可,然后将drawable下的button_shape.xml设置为控件的背景
<Button
android:id="@+id/btn_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/right"