99网
您的当前位置:首页给安卓控件设置边框border

给安卓控件设置边框border

来源:99网

前言

安卓中无法通过设置属性给控件设置边框,但是可以在Drawable下新建xml文件,然后给控件设置背景来实现:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <!-- This is the main color -->
    <item>
        <shape>
            <!--    边框颜色 -->
            <solid android:color="#808080"/>
        </shape>
    </item>
    <!-- 给View的上 左  右设置8dp的边框 -->
    <item android:bottom="10dp">
        <shape>
            <!--     View填充颜色 -->
            <solid android:color="#FFFFFF" />
        </shape>
    </item>

</layer-list>

效果:

因篇幅问题不能全部显示,请点此查看更多更全内容