Android's most comprehensive shape attributes

Source: Internet
Author: User

SHAPE has five attributes.
1. Solid indicates the solid color
Solid Android: color = "#000000" NOTE: This parameter can be left empty when used in combination with gradient.
2. Gradient indicates the gradient color
Android: startcolor = "#000000" start color
Android: centercolor = "# ff8c00" color in the middle
Android: endcolor = "# ffffff" End color
Android: angle = "45" gradient start angle. For example, 0 indicates a vertical gradient, and 90 indicates a horizontal gradient.
Android: uselevel = "true". Why?-1
Android: TYPE = "RADIAL" Gradient Pattern linear radial sweep
Note: When Android: TYPE = "RADIAL", you must set the Android: gradientradius gradient radius.
Android: gradientradius: the radius of the gradient is better to be larger, and the effect is obvious.
Android: relative position (0-0.5) of X in the gradient center of centerx = "1.0 ). Invalid when Android: TYPE = "linear"
Android: relative position of X in the gradient center of centery = "0.5" (0-1.0 ). Invalid when Android: TYPE = "linear"
3. Stroke indicates the border
Android: width = "1dp" Border Width
Android: color = "# dcdcdc" border color
Android: dashwidth = "5dp" dotted line length
Android: dashgap = "5dp" indicates the distance between the dotted lines.
4. Corners indicates the rounded corner.
Android: toprightradius = "5dp" upper right corner
Android: bottomleftradius = "5dp" bottom right corner
Android: topleftradius = "5dp" upper left corner
Android: bottomrightradius = "5dp" lower left corner
Android: radius = "5dp" indicates that the angle of the four corners is 5.
5. Padding indicates the row spacing

Write a simple XML

<? XML version = "1.0" encoding = "UTF-8"?> <Shape xmlns: Android = "http://schemas.android.com/apk/res/android"> <! -- Solid --> <solid Android: color = "# ff9d77"/> <! -- Gradient --> <gradient Android: endcolor = "# ffffff" Android: startcolor = "#000000" Android: TYPE = "RADIAL" Android: gradientradius = "100" Android: centerx = "0.5" Android: centery = "0.5" Android: angle = "90"/> <! -- Stroke --> <stroke Android: width = "2dp" Android: color = "# dcdcdc" Android: dashgap = "2dp" Android: dashwidth = "5dp"/> <! -- Rounded corner --> <corners Android: radius = "2dp"/> <padding Android: Bottom = "50dp" Android: Left = "50dp" Android: Right = "50dp" Android: top = "50dp"/> </shape>

Effect:

Mobile development QQ group: 59516399

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.