Android Button Background fillet + click Effect

Source: Internet
Author: User

Today made a button, do not want to trouble art to do pictures, and do not like square corner of the picture, using XML to do a rounded picture, done after the discovery, click on the time to see the effect of the click, XML can define the click Effect,

Just want to how can two achieve together, on-line looked under the general look over is not what I want, slowly tried, the result of both a combination OK.

1  <Button2          Android:id= "@+id/repeat"3 Android:layout_width= "Fill_parent"4 Android:layout_height= "Wrap_content"5 Android:text= "Re-start the answer"6 Android:layout_marginleft= "10dip"7 Android:layout_marginright= "10dip"8 Android:layout_margintop= "25dip"9 Android:background= "@drawable/button_style"Ten          />
Button_style as follows:

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <selectorxmlns:android= "Http://schemas.android.com/apk/res/android" >3     <Itemandroid:state_pressed= "true">4           <Shapexmlns:android= "Http://schemas.android.com/apk/res/android"5 Android:shape= "Rectangle">6             <!--deep red button with rounded corners -7             <SolidAndroid:color= "#4D0A0A"/>8             <CornersAndroid:radius= "8dip"/>9          </Shape>  Ten     </Item> One         A     <Itemandroid:state_pressed= "false"> -         <Shapexmlns:android= "Http://schemas.android.com/apk/res/android" - Android:shape= "Rectangle"> the             <!--red button with rounded corners - -             <SolidAndroid:color= "#D9534F"/> -             <CornersAndroid:radius= "8dip"/> -          </Shape>  +     </Item> -  + </selector>

Button_style.xml is an XML file that is defined under drawable.
<android:radius= "8dip"/> defines the fillet size. 

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.