效果图:

shap:
在main→res→drawable下创建shap_button文件。

shap_button的代码:
<!--定义形状有四个属性:line线形,rectangle长方形,oval圆形,ring环形-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--设置圆角的弧度有五个属性:
radius所有角,
bottomLeftRadius左下角,
bottomRightRadius右下角,
topLeftRadius左上角,
topRightRadius右下角-->
<corners android:radius="15dp"/>
<!--定义控件的渐变颜色-->
<gradient
android:startColor="#cccccc"
android:centerColor="#ccffdd"
android:endColor="#cccccc"/>
布局文件MainActivity里按钮的代码:
<Button
android:background="@drawable/shap_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="测试圆角的显示"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
shap:
在main→res→drawable下创建shap_button文件。
shap_button的代码:
<!--定义形状有四个属性:line线形,rectangle长方形,oval圆形,ring环形-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--设置圆角的弧度有五个属性:
radius所有角,
bottomLeftRadius左下角,
bottomRightRadius右下角,
topLeftRadius左上角,
topRightRadius右下角-->
<corners android:radius="15dp"/>
<!--定义控件的渐变颜色-->
<gradient
android:startColor="#cccccc"
android:centerColor="#ccffdd"
android:endColor="#cccccc"/>
布局文件MainActivity里按钮的代码:
<Button
android:background="@drawable/shap_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="测试圆角的显示"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>