Android Development Learning Note: Rounded button

Source: Internet
Author: User

The drawable-mdpi in the Res directory establishes the XML file Shape.xml, as shown in:

650) this.width=650; "Src=" http://images.cnitblog.com/blog/299408/201305/ 17101858-701c8eea74a5403b823a88700e7a88b7.jpg "/>

Shape.xml

650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>

<?xml version= "1.0"  encoding= "UTF-8"? > <shape      xmlns:android= "Http://schemas.android.com/apk/res/android"       android:shape= "Rectangle" >     <!--  Fill Color  -->      <solid android:color= "#FFFFFF"  />     <!--   Set Four corners of the button for arcs  -->     <!-- android:radius  arc radius  -->      <corners android:radius= "5dip"  />        <!--The spacing between the text inside the  padding:button and the button boundary  --> <padding     android:left= "10DP"     android:top= "10DP"     android:right= "10DP"     android:bottom= "10DP" &NBSP;/>&NBSP;</SHAPE> 

650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>

Main.xml

Shape.xml resources were used in android:background= "@drawable/shape"

650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>

<?xml version= "1.0"  encoding= "Utf-8"? > <linearlayout xmlns:android= "http// Schemas.android.com/apk/res/android "     android:orientation=" vertical "      android:layout_width= "Fill_parent"      android:layout_height= "Fill_ Parent "     > <TextView         Android:layout_width= "Fill_parent"        android:layout_height= "Wrap_ Content "       android:text=" @string/hello "     / >   <button       android:id= "@+id/roundButton"       android:text= "  Fillet button  "      android:layout_width= " Wrap_content "       android:layout_height=" Wrap_content "        android:background= "@drawable/shape"      /> </LinearLayout> 

650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>

Strings.xml
<?xml version= "1.0" encoding= "Utf-8"?> <resources> <string name= "Hello" >hello World, Roundbuttondem oactivity!</string> <string name= "App_name" >RoundButtonDemo</string> </resources>
Roundbuttondemoactivity.java

650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>

package com.android.roundbuttondemo.activity;   import android.app.activity;   import android.os.Bundle;  import android.view.View;  import  android.view.view.onclicklistener;  import android.widget.button;  import  android.widget.toast;   public class roundbuttondemoactivity extends  activity {      button roundbutton;        @Override      public void oncreate (bundle savedinstancestate)  {          super.oncreate (savedInstanceState);           setcontentview (R.layout.main);                     roundbutton= ( Button) Findviewbyid (R.id.roundbutton);         //Registering button events with anonymous classes            roundbutton.setonclicklistener (New onclicklistener ()          {                    public void onclick (VIEW&NBSP;V)                {                   toast.maketext (roundbuttondemoactivity.this,  "You clicked on the Fillet button", Toast.LENGTH_ LONG). Show ();              }           });       }  }

650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>

:

650) this.width=650; "Src=" http://images.cnitblog.com/blog/299408/201305/ 17102112-0ee2b7d5e5154f36bd99b0fe01635fe1.jpg "/>


This article is from "Little book" blog, please make sure to keep this source http://8988940.blog.51cto.com/8978940/1577508

Android Development Learning Note: Rounded button

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.