Android shape usage

Source: Internet
Author: User

From: http://www.cnblogs.com/cyanfei/archive/2012/07/27/2612023.html

Shape is used to set the shape. It can be used in selector, layout, and so on. There are 6 sub-labels. Each attribute is as follows:

 <?  XML version = "1.0" encoding = "UTF-8"  ?>  <  Shape Xmlns: Android  = "Http://schemas.android.com/apk/res/android"   >          <! --  Rounded corner  -->      <  Corners  Android: radius  = "9dp" Android: topleftradius  = "2dp"  Android: toprightradius  = "2dp"  Android: bottomleftradius  = "2dp"  Android: bottomrightradius  = "2dp"  />  <! -- Set the rounded corner radius  -->          <! --  Gradient  -->      <  Gradient  Android: startcolor  = "@ Android: color/White"  Android: centercolor = "@ Android: color/Black"  Android: endcolor  = "@ Android: color/Black"  Android: uselevel  = "True"  Android: Angle  = "45"  Android: Type  = "RADIAL"  Android: centerx = "0"  Android: centery  = "0"  Android: gradientradius  = "90"  />          <! --  Interval  -->      <  Padding Android: left  = "2dp"  Android: Top  = "2dp"  Android: Right  = "2dp"  Android: Bottom  = "2dp"  />  <! --  Interval in each direction -->          <! --  Size  -->      <  Size  Android: width  = "50dp"  Android: Height  = "50dp"  /> <! --  Width and height  -->          <! --  Fill  -->      <  Solid  Android: Color  = "@ Android: color/White"  /> <! --  Fill color  -->          <! --  Stroke  -->      <  Stroke  Android: width  = "2dp"  Android: Color = "@ Android: color/Black"  Android: dashwidth  = "1dp"  Android: dashgap  = "2dp"  />      </  Shape  > 

Fill:Set fill color

Interval:Set the interval in four directions

Size:SET SIZE

Rounded corner:If five attributes are set at the same time, the radius attribute is invalid.

Android: radius = "20dp" sets the radius of the four corners

Android: topleftradius = "20dp" sets the radius in the upper left corner.

Android: toprightradius = "20dp" sets the radius in the upper right corner.

Android: bottomleftradius = "20dp" sets the radius in the lower right corner.

Android: bottomrightradius = "20dp" sets the radius in the lower left corner.

Stroke:The dashwidth and dashgap attributes. If one of them is set to 0dp, the border is the implemented border.

Android: width =" 20dp "sets the edge width

Android: color =" @ Android: color/Black "set the edge color

Android: dashwidth =" 2dp "set the width of the dotted line

Android: dashgap = "20dp" set the interval width of the dotted line

Gradient:After the fill color is set, there is no gradient effect. The angle value must be a multiple of 45 (including 0) and only valid in type = "linear". Otherwise, an error is returned. Android: uselevel.

Start Point of the angle value

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.