Code agriculture Note 2 -- Shape of Android, androidshape

Source: Internet
Author: User

Code agriculture Note 2 -- Shape of Android, androidshape

Android has a lot of special xml files, such as commonly used selector, style, and shape. proficient in using these xml files can make our project morePersonalization.

1. Sub-tags (corners, gradient, padding, size, solid, and stroke)

1. padding and size

These two options are optional because they are used to set the padding and size of the control, which is the same as android: padding and android: layout_width in the layout file.

Padding usage

 

 

Size usage

 

 

2. corners usage

Corners is used to set the Control rounded corner attribute. With this sub-label, you can set a circular corner (such as a rounded rectangle) for the control ). It is often used for button customization.

 

 

3. Usage of stroke

Stroke is used to set stroke for the control. You can set the color and the actual line.

4. gradient and solid

Gradient and solid are set to fill color for the control. solid has only one attribute, that isAndroid: color, Use the role of solid separately and in the layout FileAndroid: backgroundSet the color to the same effect. The following describesGradient.

Although gradient also fills the control color, it is more used to fill the controlGradient color.

First, let's take a look at all the attributes of gradient.

All attributes do not need to be set every time. custom settings are made based on three gradient types. The following shows the effects of the three gradient types.

 

2. Shape attributes

We have discussed the role of the Shape sub-label above, but the Shape itself has not been discussed yet. The Shape itself can define the Shape of the current Shape, and the Shape can draw four types of images, respectively: rectangle, oval, line, and ring ).

The following shows the effects and codes of the four images.

The line has no height, so no matter how high the control is set, only one line is displayed. The color cannot be set. The width can be displayed based on the control width.

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.