在drawable文件夹中添加文件border_white.xml,编辑如下内容:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 这里是设置为四周 也可以单独设置某个位置为圆角--> <corners android:radius="5dp"/> <padding android:bottom="@dimen/info_margin" android:left="@dimen/info_margin_15" android:right="@dimen/info_margin_15" android:top="@dimen/info_margin"></padding> <stroke android:width="1dp" android:color="#FFFFFF" android:dashGap="5dp" android:dashWidth="3dp"/> </shape>
使用corners设置边框圆角;
使用padding设置边框与内容之间的距离;
使用stroke设置边框粗细、颜色;dashGap和dashWidth设置虚线边框,dashGap表示虚线中点的间隔,dashWidth表示虚线中点的大小;
效果图如下所示: