Android Custom UI Fillet button

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.