The rounded border of the control makes your app look more beautiful and, in fact, very easy to implement.
(Original address: http://blog.csdn.net/vector_yi/article/details/24463025)
To create a gray button with rounded borders, for example:
First, create a shapedrawable as a background under the Drawable folder to create abutton_rounded_background.xml File:
<shape xmlns:android = "http://schemas.android.com/apk/res/android" android:shape= "Rectangle" > < Solid android:color= "#AAAAAA"/> <corners android:radius= "15DP"/></shape>
In addition to the <solid/>,<corners/> label,,<shape/> also supports a very wide range of functional labels. Many other introductions please visit the official Android Documentation:Http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
Second, the application of Shapedrawablemain.xml in the button:
<relativelayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width= "Fill_ Parent " android:layout_height=" fill_parent " android:gravity=" center "> <button android:id = "@+id/button" android:layout_width = "Wrap_content" android:layout_height = "Wrap_content" android: Background = "@drawable/button_rounded_background" android:padding = "10DP" android:text = "@string/hello" Android:textcolor = "#000000"/></relativelayout>
at this point, a button with rounded borders has been built.
shapedrawable can be used not only in the button. It can also be applied to all controls with backgrounds, such as item in the ListView.
50 Android Development Tips (12 Add a rounded border to a control)