Fillet button Implementation
Rounded buttons are very common, and sometimes you may use PS to process rounded pictures to achieve the desired effect .
This effect is achieved today with a short code. (because it has nothing to do with engineering, it's just an effect, so I'm going to write a single XML file to do a simple demo)
1. Create an XML file under Layout with the name a
2. Drag a button directly from the project (left-click, drag directly to the white area) or write a button yourself in the code .
3. Create a folder withthe name drawable under res
4. Create an xml file named shape under the drawable folder
and write the code.
<?xml version= "1.0" encoding= "Utf-8"?>
<shape xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:shape= "Rectangle" >
<!--filled Colors--
<solid android:color= "#FFFFFF"/>
<!--set the four corners of the button arc--
<!--Android:radius Arc radius--
<corners android:radius= "25dip"/>
<!--the spacing between the text and the button boundary in the Padding:button
<padding
Android:bottom= "10DP"
android:left= "10DP"
android:right= "10DP"
android:top= "10DP"/>
</shape>
Shape is a class
where android:shape="Rectangle" is the shape of a rectangle
Of course there are other properties such as Oval ( Circle ).....
Color I set the background color to white
Padding equivalent to margin
6. now open the a.xml file and then add it under the button
Android:background= "Drawable/shape" This Code
Now you can run it and discover the effect.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How Android uses code to display components such as edit boxes as rounded corners