When you need to select a background for the application UI control, the developer adds custom colors and shapes to replace the system's default style.
Rounded borders look like a good effect, and developers just need to add a few lines of code to use this effect in your application.
Let's take a look at the following example and create a new Main.xml code:
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:id=" @+id/container " android:layout_width=" Match_parent " Android : layout_height= "match_parent" android:orientation= "vertical" > <button android:layout_width= " Wrap_content " android:layout_height=" wrap_content " android:layout_gravity=" center " Android:layout_ margintop= "50DP" android:background= "@drawable/button_rounded_background" android:gravity= "Center_ Vertical " android:padding=" 10DP " android:text=" Hello,roundcornerdemo " android:textcolor=" # FFFFFF "/></linearlayout>
Where we specify the drawable value for the Background property, but this value is not a picture, but an XML file. The file code is as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" > <solid android:color= "#02A712"/> <corners android:radius= "15DP"/></shape>
Just two lines of code. Let's take a look at the effect:
is not more gentle and feminine than the default style of square!
Like a friend can pay attention to me! Thanks for your support!
Android Development Tips Four--rounded controls to make it look more beautiful