安卓小白 直接从 Android Studio 的控件拖过来的 button
系统自带的是圆角灰色的按钮
想改变背景色,
1. 尝试直接设置 background,
结果: 背景区域扩大, 直角不好用
2. 尝试 shape
ANDROID 布局实现圆角边框
首先, 在 res 下面新建一个文件夹 drawable, 在 drawable 下面新建三个 xml 文件: shape_corner_down.xmlshape_corner_up.xml 和 shape_corner.xml, 分别是下面两个角是圆角边框, 上面两个角是圆角边框, 四个角全部是圆角边框
shape_corner_down.xml: 下面两个角是圆角边框
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#0099CC" />
<corners android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"/>
<stroke android:width="1dp" android:color="#000000"/>
</shape>
shape_corner_up.xml: 上面两个角是圆角边框
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#CCCC99" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
<stroke android:width="1dp" android:color="#000000" />
</shape>
shape_corner.xml: 四个角全部是圆角边框
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#99CCFF" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"/>
<stroke android:width="1dp" android:color="#000000" />
</shape>
来源: http://www.qdfuns.com/notes/19533/c20e96ffa213631a1c7e9ab7102ab9e4.html