The actual development of Android we generally need a rounded button, in general we can let the artist make the corresponding button picture, and then put on it, in addition we can be directly set in the layout file, you can achieve the same effect. The following is a small demo of customizing the Fillet button in the layout file.
The code is simple and implements:
Source:
Source:
Here is the main implementation of the XML layout file:
Mainactivity:
Package Com.android_drawableresource;import Android.app.activity;import Android.os.bundle;public class MainActivity Extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main);}}
Activity_main:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:layout_width=" match_parent " android:layout_height=" Match_parent " android:paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_ Horizontal_margin " android:paddingright=" @dimen/activity_horizontal_margin " android:paddingtop=" @dimen /activity_vertical_margin " tools:context=". Mainactivity "> <button android:id=" @+id/button1 " android:layout_width=" 200DP " android: layout_height= "100DP" android:layout_alignparenttop= "true" android:layout_centerhorizontal= "true" android:layout_margintop= "20DP" android:background= "@drawable/button_shape" android:text= " Custom Fillet button "/></relativelayout>
Button_shape:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" android:shape= "Rectangle" > <gradient android:angle= "0" android:endcolor= "#80FF00FF" android:startcolor= "#FFFF0000"/> <padding android:bottom= "7DP" android:left= "7DP " android:right= "7DP" android:top= "7DP"/> <corners android:radius= "10DP"/></shape>
The implementation is relatively simple, and the corresponding fillet layout can also be implemented. Need source code can go to the resources to download.