Android learning-how to fill the color of the Button and implement the rounded corner, androidbutton

Source: Internet
Author: User

Android learning-how to fill the color of the Button and implement the rounded corner, androidbutton

Create a new folder bt_shape.xml under drawable, as shown below:

1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <shape xmlns: android = "http://schemas.android.com/apk/res/android"> 3 4 android: shape = "rectangle"> // shape is used to define shape, there are four shapes (rectangular rectangle | oval | line | circle ring) 5 <solid android: color = "# 00f"/> // solid is used to set the fill shape color 6 <corners // corners is used to create a rounded corner (only used for shape is a rectangle) 7 android: topLeftRadius = "8dip" 8 android: topRightRadius = "8dip" 9 android: bottomLeftRadius = "8dip" 10 android: bottomRightRadius = "8dip"/> 11 </shape>

Use the following in activity_main.xml:

1 <Button2 android: id = "@ + id/button" 3 android: layout_width = "match_parent" 4 android: layout_height = "wrap_content" 5 android: background = "@ drawable/bt_shape" // reference 6 android: text = "OK" 7 android: textColor = "# fff" 8/>

The implementation result is as follows:

Related Article

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.