Custom black stroke, white background, background with rounded corner, stroke rounded corner
First, write an xml file "solid_c9c9c9.xml" in the drawable folder.
1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <shape xmlns: android = "http://schemas.android.com/apk/res/android"> 3 android: shape = "rectangle"> <! -- Square --> 4 <stroke5 android: width = "1dp" 6 android: color = "@ color/color_c9c9c9"/> <! -- Stroke --> 7 <solid android: color = "@ color/white"/> <! -- Background --> 8 <corners android: radius = "5dp"/> <! -- Rounded corner --> 9 </shape>
View Code
Then, use the xml file to set the background in the layout file.
1 <LinearLayout2 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
: