定制 黑色描边、白色背景、带圆角 的背景

首先,在drawable文件夹写一个xml文件solid_c9c9c9.xml

1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android">
3     android:shape="rectangle"><!--方形-->
4     <stroke
5         android:width="1dp"
6         android:color="@color/color_c9c9c9" /><!--描边-->
7     <solid android:color="@color/white" /><!--背景-->
8     <corners android:radius="5dp" /><!--圆角-->
9 </shape>
View Code

然后,在布局文件中直接用这个xml文件设置背景

1 <LinearLayout
2         android:layout_width="match_parent"
3         android:layout_height="40dp"
4         android:orientation="horizontal"
5         android:layout_margin="@dimen/padding_15"
6         android:background="@drawable/solid_c9c9c9">
7 
8     </LinearLayout>
View Code

效果图:

原文地址:https://www.cnblogs.com/shenchanghui/p/6089934.html