【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