Properties of shape in XML in Android

Source: Internet
Author: User
Tags dashed line

Some of the properties of shape are always forgotten, every time to find, in order to facilitate my own record, convenient later forget to look at these properties.

There are several properties in shape rectangle, oval, line, ring
1. Annular ring
Set the Shape property to ring type in the Shape tab
And then inShape LabelSet the following properties (these properties can only be used when the shape value is ring)
Android:innerradiusThe radius of the inner ring, the dimension unit is DP (does not set this parameter, there will be a default value)
android:thicknessThe width of the ring, the unit of dimension is DP (the parameter must be set)
Android:uselevelA Boolean value that is False if you use the value as true for levellistdrawable. (This property must be set, otherwise invisible effect, temporarily set to false)

Android:innerradiusratioFloating point, which represents the radius of the inner ring at the width ratio of the ring. The default is 9, that is, the width of the ring multiplied by 9 and divided by 2 is the length of the inner ring radius
Android:thicknessratioFloating point, which represents the thickness of the ring in the width ratio of the ring.

2. Oval Oval
The size of the ellipse can be set by the child label size, which is rounded when the width and height are equal. Generally no longer the child label size is set to width height, but the width of the control is set.

3. Rectangular Rectangle
The size of the rectangle can be set by the child label Size label, which is square when the width and height are equal. Generally no longer the child label size is set to width height, but the width of the control is set.
When shape is not specified, the default is rectangle

4. Straight Line
You can draw a line, or you can draw a dash

There are gradient, corners, padding, size, solid, stroke in the shape's child tags
1. Stroke of line strokes of a shape
android:width= "Dimension"Thickness of the line
android:color= "Color"The color of the line
The following two properties are used when a dashed line is set, and the solid lines do not set these two properties
android:dashwidth= "Dimension"Length of dashed lines per section
android:dashgap= "Dimension"Direct gap width for each section of the dash

Note:This property must be set when drawing ring,line, it is necessary to set the stroke when drawing oval,rectangle, do not need to set

2. Fill Color Solid
android:color= "Color"Use this property when you need to fill the inner color of a shape

Note:Do not set this property when drawing line, in the painting ring,oval,rectangle is required to set the solid, need not set the hollow

3. Set Picture size
android:width= "Dimension"Set width
android:height= "Dimension"Set height

Note:When you draw oval, the width and height equal is the circle, in the picture rectangle is the width height equal is the square, but generally does not set here, basically in the control set wide height

4. Internal margin padding
android:left= "Dimension"Set left inner margin
android:top= "Dimension"Set upper padding
android:right= "Dimension"Set Right padding
android:bottom= "Dimension"Set the bottom padding

Note:This property is not normally set

5. Fillet Corners
android:radius= "Dimension"Full radius of rounded corners
All of the above have rounded corners, do not coexist with the following four properties, either are rounded, or are set to each corner according to the following properties
android:topleftradius= "Dimension"Corner radius of upper left corner
android:toprightradius= "Dimension"Corner radius of upper right corner
android:bottomleftradius= "Dimension"Corner radius of the lower left corner
android:bottomrightradius= "Dimension"Corner radius in lower right corner

Note:Rounded corners are generally used in rectangle cases

6. Gradient Gradient
android:type=["Linear" | "Radial" | "Sweep"]There are 3 gradient types, linear gradient (default)/radial gradient/swept gradient
android:startcolor= "Color"Color of the start point of the gradient
android:centercolor= "Color"The color of the middle point of the gradient, between the start and end points
android:endcolor= "Color"Color of gradient end point
android:angle= "integer"Gradient angle, must be a multiple of 45, 0 is from left to right, 90 is top to bottom
android:gradientradius= "float"The radius of the gradient that can be used only if the gradient type is radial
android:centerx= "float"The equivalent position of the gradient center x, in the range 0~1, left to right, default 0.5
android:centery= "float"The equivalent position of the gradient center y, range 0~1, top to bottom, default 0.5
android:uselevel= "Boolean"Set to True when using levellistdrawable. Fade effect when set to False

Note:The Angle property is valid when the type is linear, and the Gradientradius property must be set when the type is radial, and the sweep and CenterX properties are valid when the type is centery.

This article is from the "Remember" blog, be sure to keep this source http://ziruo.blog.51cto.com/10107518/1680349

Properties of shape in XML in Android

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.