Basic use of shape in Android

Source: Internet
Author: User

Basic use of shape in Android

Shape is used to set the shape. It can be used in selector, layout, etc. If you click the effect, you don't need to cut the UI. You can use shape directly, which is convenient and quick. A new shape. xml is a rectangle by default. You can use android: shape = to set a specific shape. There are four types: rectangle, oval elliptical shape, line, and ring. Shape has six sub-labels, each of which has the following attributes:

 

 
  
   
    
     
       
       
      
     
    
   
  
 
Fill: Set the fill color

 

Interval: Set the interval in four directions.

Size: set the size.

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

Android: Radius = 20dp set the Radius of the four corners

Android: topLeftRadius = 20dp: Set the radius in the upper left corner.
Android: topRightRadius = 20dp set the radius in the upper right corner
Android: bottomLeftRadius = 20dp
Android: bottomRightRadius = 20dp: Set 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 set the Edge width
Android: color = @ android: color/black sets 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: No gradient effect after the fill color is set. The angle value must be a multiple of 45 (including 0). It is valid only when type = linear. Otherwise, an error is returned. Android: useLevel.

 

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.