Android layer-list Clip Shape Selector Detailed introduction and use

Source: Internet
Author: User

Layer-list, which is often used in the Android UI design, is critical to shape's role in beautifying the controls.
    • Shape
      1. Role: Defining Geometry in XML
      2. Property:
        <shape>  Android:shape=["rectangle" | "oval" | "line" | "ring"]   其中rectagle矩形,oval椭圆,line水平直线,ring环形
<?XML version= "1.0" encoding= "Utf-8"?> <Shapexmlns:android= "Http://schemas.android.com/apk/res/android"Android:shape=["Rectangle"| "Oval" | "Line" | "Ring"]>     <GradientGradient Android:angle= "integer"gradient angle, 0 from left to right, 90 for bottom to top, number 45 for integer, default to 0; Android:centerx= "integer"Android:centery= "integer"Android:centercolor= "integer"Android:endcolor= "Color"End Color Android:gradientradius= "integer"Android:startcolor= "Color"Starting color Android:type=["Linear"| "Radial" | "Sweep"] gradient style liner linear gradient radial ring gradient sweep android:useslevel=["true"| "False"]/>     <SolidFill
Android:color= "Color"The color of the fill/>     <StrokeStroke Android:width= "integer"width of stroke android:color= "Color"the color of the stroke android:dashwidth= "integer"indicates the width of the horizontal line Android:dashgap= "integer"represents the distance between horizontal lines/>     <paddingAndroid:left= "integer"Android:top= "integer"Android:right= "integer"Android:bottom= "integer" />     <Cornersrounded Corners Android:radius= "integer"the larger the radius of the fillet the greater the rounded Android:topleftradius= "integer"Top left corner radius Android:toprightradius= "integer"Top right corner radius Android:bottomleftradius= "integer"Lower left fillet corner radius Android:bottomrightradius= "integer"Corner radius of right bottom corner/> </Shape>
    • Layer-list, a plurality of pictures or more than two effects in order to cascade;
<?XML version= "1.0" encoding= "Utf-8"?><layer-listxmlns:android= "Http://schemas.android.com/apk/res/android" >    <ItemAndroid:id= "@android: Id/background">        <Shape>            <CornersAndroid:radius= "0dip" />            <SolidAndroid:color= "#FDE5A2" />        </Shape>    </Item>    <ItemAndroid:id= "@android: id/secondaryprogress">        <Clip>            <Shape>                <CornersAndroid:radius= "0dip" />                <GradientAndroid:angle= "+"Android:centercolor= "#80ffb600"Android:centery= "0.75"Android:endcolor= "#a0ffcb00"Android:startcolor= "#80ffd300" />            </Shape>        </Clip>    </Item>    <ItemAndroid:id= "@android: id/progress">        <Clip>            <Shape>                <CornersAndroid:radius= "0dip" />                <SolidAndroid:color= "#FD2702" />            </Shape>        </Clip>    </Item></layer-list>

Layer-list cascading styles correspond to layerdrawable in the program, using the following methods:

Resources resources =new drawable[2]; layers[0] = r.getdrawable (r.drawable.white); layers[1] =new  layerdrawable (Layers) ((ImageView) Findviewbyid (R.id.imageview)). Setimagedrawable (layerdrawable);

Reference article:

http://tbwisk.github.io/lessons/2015/01/14/Android%E5%BC%80%E5%8F%91%EF%BC%8Cshape%EF%BC%8Cselector%EF%BC% 8clayer-list%e4%bb%8b%e7%bb%8d/

Android layer-list Clip shape Selector details and use

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.