Android-shape is simple to use, Android-shape

Source: Internet
Author: User

Android-shape is simple to use, Android-shape

Shape

 

Let's take a look at the built-in EditText and Button shapes.

 

The following figure shows the effect after adding a shape.

 

 

To put it simply, a shape can add a background border to the component, and a rounded corner can be used with selector.

 

ShapeXXX. xml is defined in the drawable directory.

 

The

<? Xml version = "1.0" encoding = "UTF-8"?> <! -- Rectangle oval line ring --> <shape android: shape = "rectangle" xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Rounded corner of the four corners --> <corners android: radius = "5dp"/> <! -- Padding --> <padding android: bottom = "6dp" android: left = "5dp" android: right = "5dp" android: top = "6dp"/> <! -- Fill color to add as needed --> <solid android: color = "# FFFAE3"/> <! -- Border color needs to be added, --> <stroke android: color = "#87 CEFA" android: width = "1dp"/> </shape>

 

The buttons use the same definition.

<? Xml version = "1.0" encoding = "UTF-8"?> <! -- Rectangle oval line ring --> <shape android: shape = "rectangle" xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Rounded corner of the four corners --> <corners android: radius = "8dp"/> <! -- Padding --> <padding android: bottom = "5dp" android: left = "3dp" android: right = "3dp" android: top = "5dp"/> <! -- Fill color --> <solid android: color = "# 09A3DC"/> <! -- Border color --> <stroke android: color = "#88000000" android: width = "1dp"/> </shape>

 

Use group in layout in the background attribute

<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: orientation = "vertical" android: layout_width = "match_parent" android: layout_height = "match_parent"> <EditText android: layout_margin = "10dp" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: background = "@ drawable/shap_et" android: hint = "Enter the user name"/> <Button android: layout_margin = "10dp" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: textColor = "# ffffff" android: background = "@ drawable/shap_btn" android: text = "OK"/> </LinearLayout>

 

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.