Shap圆角

来源:互联网 发布:dnf如果合约到期知乎 编辑:程序博客网 时间:2024/05/31 19:23
效果图:

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"/>
0 0
原创粉丝点击