【Android开发】控件外边框自定义

1、在drawable里面新建自定义的资源文件shape

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="10dp"/>
    <solid android:color="@color/transparent"/>
    <stroke
        android:width="3dp"
        android:color="@color/loginGreenColor"/>

    <padding
        android:bottom="5dp"
        android:left="10dp"
        android:right="10dp"
        android:top="5dp"/>
</shape>

solid:控件的颜色

stroke:边框的大小和颜色   width:边框的宽度  color:外边框的颜色

corners:设置控件边角的弧度,可设置radius的大小设置边角的弧度

2、在控件的background属性里面引用自定义的资源文件即可

posted @ 2019-06-05 17:38  浪里小白龙呼呼呼  阅读(1189)  评论(0编辑  收藏  举报