Create a new Btn_shape.xml file under 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 "> 4 <solid Android:color= "#ffffff"/> 5 <corners 6 android:topleftradius= "8dip" 7 android:toprightradius= "8dip 8 android:bottomleftradius=" 8dip " 9 android: bottomrightradius= "8dip"/> </shape>
First explain the above code:
1.shape for defining shapes, there are four shapes (rectangular Rectangle| Oval Oval | straight Line | round ring).
The 2.solid is used to set the color of the fill shape.
3.corners is used to create rounded corners (only for shapes that are rectangles).
Topleftradius, Toprightradius, Bottomleftradius, Bottomrightradius respectively set the radius of upper left, upper right, bottom left, bottom right corner.
How to use:
android:background= "@drawable/btn_shape"
1 <button2 android:layout_width= "Wrap_content"3 android:layout_height= " Wrap_content "4 android:id=" @+id/button "5 android:background=" @drawable/btn_shape " 6 />
:
1 Reference URL: 2 http://Developer.android.com/guide/topics/resources/drawable-resource.html#shape
Android Learning-Achieve rounded button