Android Learning-Achieve rounded button

Source: Internet
Author: User

Create a new Btn_shape.xml file under the Drawable folder:

1 <?xml version= "1.0" encoding= "Utf-8"?> 2 <shape xmlns:android= "/http Schemas.android.com/apk/res/android " 3     android:shape=" Rectangle "> 4     <solid Android:color= "#ffffff"/> 5     <corners  6         android:topleftradius= "8dip" 7         android:toprightradius= "8dip            8         android:bottomleftradius=" 8dip " 9         android: bottomrightradius= "8dip"/> </shape>

First explain the above code:

1.shape for defining shapes, there are four shapes (rectangular Rectangle| Oval Oval | straight Line | round ring).

The 2.solid is used to set the color of the fill shape.

3.corners is used to create rounded corners (only for shapes that are rectangles).

Topleftradius, Toprightradius, Bottomleftradius, Bottomrightradius respectively set the radius of upper left, upper right, bottom left, bottom right corner.

How to use:

android:background= "@drawable/btn_shape"

1   <button2         android:layout_width= "Wrap_content"3         android:layout_height= " Wrap_content "4         android:id=" @+id/button "5         android:background=" @drawable/btn_shape " 6         />

1 Reference URL: 2 http://Developer.android.com/guide/topics/resources/drawable-resource.html#shape 

Android Learning-Achieve 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.