Android development-Implementation of rounded corner buttons and draw straight lines

Source: Internet
Author: User

We usually think that the buttons provided by the system are not beautiful enough. At this time, we can define a button by ourselves to meet our own needs. Here we can implement a rounded button. You need to create an xml file in the drawable folder and use shape as the root label. You can use the following shape to achieve the requirement: [html] <? Xml version = "1.0" encoding = "UTF-8"?> <Shape xmlns: android = "http://schemas.android.com/apk/res/android" android: shape = "rectangle"> <! -- Fill color (white) --> <solid android: color = "# 0000FF"/> <! -- Set the four corners of the button to an arc --> <! -- Android: radius arc radius --> <corners android: radius = "5dip"/> <! -- Padding: The interval between the text in the Button and the Button boundary --> <padding android: left = "10dp" android: top = "10dp" android: right = "10dp" android: bottom = "10dp"/> </shape> at the same time, you must add the following code to the Button tag in the layout file for declaration: [html] android: under background = "@ drawable/shape", I want to draw a straight line in the Activity, which is easy to implement. I only need to use View as the root label and set the height to 1 px, the following is an implementation statement: [html] <View android: layout_height = "1px" android: background = "# ff0000" android: layout_width = "fill_parent"> </View> is implemented:

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.