[From]: http://iaiai.iteye.com/blog/1102958
To set border rounded corners, you can define an XML file in the drawable-mdpi directory:
Java Code
- <? XML version ="1.0"Encoding ="UTF-8"?>
-
- <Shape xmlns: Android =Http://schemas.android.com/apk/res/android">
-
- <Solid Android: color ="#000000"/>
-
- <Corners Android: topleftradius ="10dp"
-
- Android: toprightradius ="10dp"
- Android: bottomrightradius ="10dp"
-
- Android: bottomleftradius ="10dp"/>
-
- </Shape>
Explanation: solid indicates the fill color. For simplicity, black is used here.
Corners indicates the rounded corner. Note that bottomrightradius is in the lower left rather than the lower right corner, and bottomleftradius is in the lower right corner.
Of course, the above effects can also be set as follows:
Java code
- <Corners Android: radius ="5dp"/>
To reference this XML, you only need @ drawable/corners_bg.xml:
Java code
- Android: Background ="@ Drawable/corners_bg"
Main. xml:
Java code
- <? XML version ="1.0"Encoding ="UTF-8"?>
-
- <Linearlayout xmlns: Android =Http://schemas.android.com/apk/res/android"
-
- Android: Orientation ="Vertical"Android: layout_width ="Fill_parent"
-
- Android: layout_height ="Fill_parent"Android: Background ="# Ffffff">
-
- <Relativelayout Android: Id ="@ + ID/login_div"
- Android: layout_width ="Fill_parent"Android: layout_height ="150dip"
-
- Android: padding ="15dip"Android: layout_margin ="15dip"
-
- Android: Background ="@ Drawable/corners_bg">
-
- </Relativelayout>
-
- </Linearlayout>
Running result: