【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属性里面引用自定义的资源文件即可


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM