A detailed explanation of the shape of Android development

Source: Internet
Author: User
Tags dashed line

In the daily development, we will encounter some button, Textview ... The background of the control is rounded rectangle, circle ... And so on, and the Android default control background rectangle is inconsistent, this time the role of shape is reflected, we can draw a lot of our unexpected background pattern according to the Shape property, below I will all shape properties are introduced. This article refers to the sub http://keeganlee.me/post/android/20150830.

1 Shape Label:

    Android:shape:

      Rectangle: Rectangle, default shape, can draw right-angle rectangle, rounded rectangle, arc, etc.

      Oval: Ellipse, used more is to draw a circle

      Line: Linear, can draw solid lines and dashed lines

      Ring: Annular, can draw loop progress bar

    android:tint: Coloring shape

   Android:tintmode: shading Mode (see article: http://blog.csdn.net/u010687392/article/details/47399719 for tint and Tintmode)

Android:dither: enables the jitter of bitmaps when the bitmap's pixel configuration differs from the screen (for example: ARGB 8,888-bit graph and RGB 565 screen), and when the value is "false", the jitter is deactivated. The default value is true.

Android:visible: It's unclear what the hidden control is.

Android:uselevel: If true, it can be used in levellistdrawable. This should normally be "false", otherwise the shape will not be displayed.

android:thickness: The thickness of the ring, refers to the distance between the inner ring and the outer ring. (only for Shape ring)

android:thicknessratio: floating point, the width ratio of the ring to represent the thickness of the ring, the default is 9, indicating that the ring thickness is the width of the ring divided by 9, the value will be android:thickness overwritten (only for shape ring)

android:innerratio: Inner ring radius (only for shape ring)

    android:innerradiusratio: Floating point, which represents the radius of the inner ring at the width ratio of the ring, by default 3, which means that the inner ring radius is the width of the ring divided by 3, which is the value of Android: Innerradius overlay (only for shape ring)

2 Shape under Size Label: Set shape width height value

    android:height: Height

    android:width: Width

    Note : Only the width of the control is set to Wrap_content, where the wide well paid works, but the minimum width and height value. That is, when the width of the control is greater than the value you specify here, it changes (wrap_content!!! )

   

3 Shape under solid label: Set shape fill Color

    Android:color: Specifying a color value

    

4 shape under padding tag: Set the distance between content and boundary

    android:left: Left inner margin

    android:top: Upper inner margin

    android:right: Right inner margin

    Android:bottom: Left inner margin

5 Shape under Corners Label: Set Four corners of rounded corners

    Android:radius: four fillet fillet

    Android:topleftradius: Rounded corner of upper left corner

    Android:toprightradius: Rounded corners in the upper right corner

    Android:bottomleftradius: Rounded corners of the lower left corner

    android:bottomrightradiusleft: Rounded corners in the lower right corner

    Caveats : RADIUS attribute values can be overridden by four other properties.

6 Shape under Stroke label: set outer boundary of shape

    android:color: The color of the boundary line

    android:width: The width of the boundary line

    android:dashwidth: The width of the segment dashed line (you can interpret the boundary lines as a segment without interval connections)

    android:dashgap: Interval of dashed segments

Gradient tab under Shape 7: Set shape gradient

    android:type: type of gradient

      linear: linear gradient, default gradient type

      radial: Radial gradient, when setting this item, you must set the Android:gradientradius property

      sweep: Scanning gradients

    android:angle: Gradient angle, linear gradient (linear is also the default gradient type ) is valid, must be a multiple of 45, 0 means left to right, 90 means bottom to top

    Android:centerx: The relative x-coordinate of the gradient center, which is only valid at the time of the radial gradient (radial), between 0.0 and 1.0, which is 0.5 by default, indicating that it is in the middle

    android:centery: The relative x-coordinate of the gradient center, when the radiation gradient (radial is valid, between 0.0 and 1.0, the default is 0.5, which means that in the middle

    android:uselevel: If true, it can be used in levellistdrawable. This should normally be "false", otherwise the shape will not be displayed.

    android:startcolor: The color at which the gradient starts

    android:centercolor: Color in the middle of the gradient

    android:endcolor: Color of gradient end

    Android:gradientradius: The radius of the gradient, only used when the gradient type is radial

At this point, all the properties about the Shape property and the child label are all described.

If you would like to see the use, please see the following articles:

1 http://keeganlee.me/post/android/20150830

2 http://blog.csdn.net/rflyee/article/details/20785495

A detailed explanation of the shape of Android development

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.