Android Shape detailed

Source: Internet
Author: User

Shape--> Shape Properties:

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

Solid: Sets the color of the shape fill, only android:color one property

Android:color the color of the fill
padding: Sets the inner space between the content and shape boundaries, setting the distance between the left and right

One:

   Rectangle

        

  • Solid: Sets the color of the shape fill, only android:color one property

    • Android:color The color of the fill
  • padding: Sets the inner space between the content and shape boundaries, setting the distance between the left and right

    • Android:left left inner spacing
    • android:right Right inner spacing
    • android:top spacing between the upper and inner
    • Android:bottom under inner space
  • Gradient : Sets the gradient color of a shape, which can be a linear gradient, a radiation gradient, a sweep gradient

    • android:type   The type of gradient
      • linear   linear gradient, default gradient type
      • radial   radial gradient, Android:gradientradius must also be set when setting this item
      • sweep   scanning gradients
    • android:startcolor   gradient start color
    • android:endcolor   gradient end color
    • android:centercolor   Colors in the middle of the gradient
    • android:angle   Gradient angle, linear gradient only valid, must be a multiple of 45, 0 means left to right, 90 means bottom to top
    • Android:centerx   Gradient Center relative x coordinate, only valid for radial gradient, between 0.0 and 1.0, default is 0.5, mean between the middle
    • android:centery   Gradient Center relative x coordinate, only valid for radial gradient, between 0.0 and 1.0, default is 0.5, mean between the middle
    • Android:gradientradius The radius of the   gradient, only used when the gradient type is radial
    • android:uselevel   If true, you can use it in levellistdrawable
  • Corners: Set the fillet, only for the rectangle type, can be set four angles of different radii of the fillet, when the radius is large, such as 200DP, can be turned into a curved edge

    • Android:radius fillet radius, which is overridden by each of the following specific fillet properties
    • Android:topleftradius radius of the upper left corner
    • The radius of the upper right corner of the Android:toprightradius
    • Android:bottomleftradius radius of the lower left corner
    • Android:bottomrightradius radius of the lower right corner
  • Stroke: Sets the stroke to stroke narimi or dashed lines.

    • android:color Color of strokes
    • android:width width of stroke
    • android:dashwidth The horizontal line length when the dash is set
    • Android:dashgap to set the distance between dashes when dashed

    • |


      Oval oval is used to draw ellipses, and in practical applications, more is to draw a circle, such as a message, a circular button, etc.
    • Size: Set the shape's default sizes to set width and height
      • android:width Width
      • android:height Height
    • Here is an example:
    • <?xml version= "1.0" encoding= "Utf-8"?><!--android:shape specified shape type, default rectangle-<shapeXmlns:android="Http://schemas.android.com/apk/res/android"Android:shape="Oval"><!--padding set the inner spacing--<paddingandroid:bottom= "4DP" android:left= "4DP" android:right= "4DP" android:top= "4DP" /> <!--size set shape and <size  Android:width= "40DP" android:height= "40DP" / > <!--gradient set gradient--<gradient android:endcolor=< Span class= "s" > "#000000" android:gradientradius= "40DP" android: Startcolor= "#FFFFFF" android:type= "radial" / ></SHAPE>            
    •  < Span class= "NT" > < Span class= "NT" > < Span class= "s" >     

      <textview    android:layout_width="wrap_content"    android:layout_height="Wrap_content"    android:gravity=android:layout_margin=android:text=android:textsize=android: textcolor=android:background=/>          
      Three: line lines are mainly used to draw split lines, which are achieved by combining the stroke and size features, first look at the dotted code:
    • <?xml version= "1.0" encoding= "Utf-8"?> xmlns:android="http://schemas.android.com/apk/res/ Android "    android:shape=" line "android:width=android:color=android:dashgap=  android:dashwidth=android:height=/></shape>       

      When drawing a line, there are a few features that you must know:

        1. Only draw horizontal line, can not draw vertical line;
        2. The height of the line is set by the Android:width property of the stroke;
        3. The Android:height property of size defines the height of the entire shape area;
        4. The height of size must be greater than the width of the stroke, otherwise the line cannot be displayed;
        5. The line is centered in the entire shape area;
        6. The left and right side of the line will leave blank spacing, the thicker the line, the larger the blank;
        7. The view that references the dashed line needs to add the attribute Android:layertype, the value is set to "software", otherwise the dashed line is not displayed.

      Four: Ring Circle
    • First, some properties of the shape root element apply only to the ring type, so let's take a look at these properties:

      • Radius of inner ring of Android:innerradius
      • android:innerradiusratio floating Point, which represents the radius of the inner ring at the width ratio of the ring, the default is 3, which means that the inner ring radius is the width of the ring divided by 3, and the value is overwritten by Android:innerradius
      • Thickness of android:thickness 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
      • Android:uselevel is generally false, otherwise the ring cannot be displayed and is set to true only when used as levellistdrawable
    •  
      • <gradient/>---gradient
      • < stroke width= "1DP" color= "@android: Color/black"/> The color width of the border

If you want the ring to turn up, then add a layer of rotate to the outside.

    

<progressbar
Android:layout_width= "100DP"
android:layout_height= "100DP"
android:indeterminatedrawable= "@drawable/rotate_shape"/>

Android Shape detailed

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.