Set Corners_bg.xml
Set border fillets You can define an XML in the DRAWABLE-MDPI directory:
<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android= "http://schemas.android.com/apk/res/ Android "> <solid android:color=" #FFFFFF "/> <corners android:topleftradius=" 10DP " Android : toprightradius= "10DP" android:bottomrightradius= "10DP" android:bottomleftradius= "10DP"/>
Explain:
Solid represents the fill color, in order to be simple, here is white.
And the corners is the fillet, note that here Bottomrightradius is the lower left corner instead of the lower right corner, Bottomleftradius the lower right corner.
The above effect can also be set as follows:
<corners android:radius= "5DP"/>
Reference Corners_bg.xml
If you want to reference this XML, you need only @drawable/corners_bg.xml:
Application examples
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:background=" #E1E0DE " android:orientation= "vertical" > <textview android:id= "@+id/textview1" android:layout_width= "match _parent "android:layout_height=" 50DP "android:background=" #2B3439 "android:gravity=" center "an" droid:text= "found" android:textcolor= "#FFFFFF" android:textsize= "20sp"/> <linearlayout Android : id= "@+id/login_div" android:layout_width= "fill_parent" android:layout_height= "50DP" android:layout_m Argin= "10DP" android:background= "@drawable/corners_bg" android:gravity= "center_vertical" Android:padd ing= "10DP" > <imageview android:id= "@+id/imageview1" android:layout_width= "wrap_content "Android:layout_height="Wrap_content" android:src= "@drawable/find_more_friend_photograph_icon"/> <textview an Droid:id= "@+id/textview2" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_marginleft= "14DP" android:text= "friend Circle" android:textcolor= "#000" an Droid:textsize= "18sp"/> </LinearLayout> <linearlayout android:layout_width= "Fill_parent" android:layout_height= "101DP" android:layout_margin= "10DP" android:background= "@drawable/corners_bg" android:orientation= "vertical" android:padding= "10DP" > <linearlayout android:layout_width= "Wrap_content" android:layout_height= "50DP" > <imageview android:layout_width= " Wrap_content "android:layout_height=" wrap_content "android:src=" @drawable/find_more_friend_s Can "/> < TextView android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_marginleft= "14DP" android:text= "Sweep" android:textcolor= "#000" Android:textsize= "18sp"/> </LinearLayout> <linearlayout android:layout_width= "W Rap_content "android:layout_height=" 50DP "android:layout_centervertical=" true "> <i Mageview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:src= "@drawable/come_from_shake"/> <textview android:layout_width= "Wrap_conte NT "android:layout_height=" Wrap_content "android:layout_marginleft=" 14DP "and Roid:text= "Shake" android:textcolor= "#000" android:textsize= "18sp"/> </linearlay Out> </linearlayout> <linearlayout android:layout_width= "fill_parent" android:layout_height= "101DP" Andro Id:layout_margin= "10DP" android:background= "@drawable/corners_bg" android:orientation= "Vertical" Android oid:padding= "10DP" > <linearlayout android:layout_width= "wrap_content" Android:layout_h eight= "50DP" > <imageview android:layout_width= "wrap_content" android:layou t_height= "Wrap_content" android:src= "@drawable/find_more_friend_near_icon"/> <textview Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" Androi d:layout_marginleft= "14DP" android:text= "android:textcolor=" #000 "Andro Id:textsize= "18sp"/> </LinearLayout> <linearlayout android:layout_width= "Wrap_conten T "Android:layout_height= "50DP" android:layout_centervertical= "true" > <imageview Android:la Yout_width= "Wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/come_f Rom_bottle "/> <textview android:layout_width=" Wrap_content "android:layout _height= "Wrap_content" android:layout_marginleft= "14DP" android:text= "Drifting Bottle" an Droid:textcolor= "#000" android:textsize= "18sp"/> </LinearLayout> </LinearLayout> <linearlayout android:id= "@+id/login_div" android:layout_width= "Fill_parent" Android:layout_hei ght= "50DP" android:layout_margin= "10DP" android:background= "@drawable/corners_bg" android:gravity= "ce Nter_vertical "android:padding=" 10DP "> <imageview android:id=" @+id/imageview1 " Android:layout_width= "WRAp_content "android:layout_height=" wrap_content "android:src=" @drawable/more_game "/> < TextView android:id= "@+id/textview2" android:layout_width= "Wrap_content" Android:layout_h eight= "Wrap_content" android:layout_marginleft= "14DP" android:text= "Game Center" Android:textcol Or= "#000" android:textsize= "18sp"/> </LinearLayout></LinearLayout>
Achieve rounded borders in Android layouts