<span id="Label3"></p> <dl id="fontzoom" class="box_body"> <dd id="Article"> <span style="font-size: 16px;"><span style="font-size: 16px;">today, with shape, There are a lot of properties here, and here I'm documenting the use of each attribute and what it means</span> .</span> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <pre><span style="font-size: 16px;"><?xml version= "1.0" encoding= "utf-8"?> <<span style="color: #000000;"><span style="color: #000000;">Shape Xmlns:android</span></span>= "http://schemas.android.com/apk/res/android"<span style="color: #000000;"><span style="color: #000000;">Android:shape</span></span>=["rectangle" | "oval" | "line" | "ring"] > <<span style="color: #000000;"><span style="color: #000000;">Corners Android:radius</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:topleftradius</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:toprightradius</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:bottomleftradius</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:bottomrightradius</span></span>= "integer"/> <<span style="color: #000000;"><span style="color: #000000;">Gradient Android:angle</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:centerx</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:centery</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:centercolor</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:endcolor</span></span>= "color"<span style="color: #000000;"><span style="color: #000000;">Android:gradientradius</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:startcolor</span></span>= "color"<span style="color: #000000;"><span style="color: #000000;">Android:type</span></span>=["linear" | "radial" | "sweep"<span style="color: #000000;"><span style="color: #000000;">] Android:uselevel</span></span>=["true" | "false"]/> <<span style="color: #000000;"><span style="color: #000000;">padding Android:left</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:top</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:right</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:bottom</span></span>= "integer"/> <<span style="color: #000000;"><span style="color: #000000;">size Android:width</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:height</span></span>= "integer"/> <<span style="color: #000000;"><span style="color: #000000;">Solid Android:color</span></span>= "color"/> <<span style="color: #000000;"><span style="color: #000000;">Stroke Android:width</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:color</span></span>= "color"<span style="color: #000000;"><span style="color: #000000;">Android:dashwidth</span></span>= "integer"<span style="color: #000000;"><span style="color: #000000;">Android:dashgap</span></span>= "integer"/> </shape></span></pre> <p><p></p></p> <span style="font-size: 16px;">the <span style="font-size: 16px;">above paragraph is the format used by shape to see how to Use:</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><shape></span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">define this as a gradientdrawable, which must be the root Element. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:shape</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">define the value of shape, which must be one of the following:</span></span> <span style="font-size: 16px;">the <span style="font-size: 16px;">"rectangle" matrix, which is also the default shape</span></span> <span style="font-size: 16px;">oval <span style="font-size: 16px;">Ellipse</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">"line" A level of straight lines. This shape must use the <stroke> element to define the width of this line</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">"ring" Ring</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">The following properties are used only when android:shape= "ring":</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:innerradius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimensions. The radius of the inner ring. A size value (dip, and so On) or a size resource. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:innerradiusratio</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">float Type. This value represents the scale of the inner ring, for example, if android:innerradiusratio = "5", then the inner radius is equal to the width of the ring divided by 5. This value will be rewritten by android:innerradius. The default value is 9. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">android:thickness</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimensions. The thickness of the ring is a resource of a dimension value or Dimension. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:thicknessratio</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">float Type. The ratio of thickness. For example, If you android:thicknessratio= "2", then the thickness is equal to the width of the ring divided by 2. This value is overridden by android:innerradius, and the default value is 3. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:uselevel</span></span> <span style="font-size: 16px;">the <span style="font-size: 16px;">Boolean Type. If used in levellistdrawable, then it is True. False if it usually does not appear. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><corners></span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">creates a fillet for shape, only used when shape is rectangle. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:radius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The radius of the Fillet. Is overridden by each of the following specific fillet properties. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:topleftradius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. Top-left set the radius of the upper-left corner</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:toprightradius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. Top-right set the radius in the upper-right corner</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:bottomleftradius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. Set the radius in the lower right corner</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:bottomrightradius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. Set the radius of the lower left corner</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><gradient></span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Specifies the gradient color for this shape. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:angle</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Integer. The angle of the Gradient. 0 represents from left to Right. 90 represents bottom to Top. Must be a multiple of 45, default is 0</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:centerx</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Float. The relative x-coordinate of the gradient center, between 0 and 1.0. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:centery</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Float. The relative y-coordinate of the gradient center, between 0 and 1.0. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:centercolor</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Color. The optional color Value. Based on between StartColor and Endcolor. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:endcolor</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Color. The End Color. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:gradientradius</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Float. The radius of the Gradient. Only used in android:type= "radial"</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:startcolor</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Color. The starting color Value. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:type</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Keyword. Gradient mode, One of the following values:</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">"linear" Linear Gradient. This is also the default mode</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">"radial" radiation Gradient. StartColor is the color of the radiation center</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">"sweep" Scan Line Gradient. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:uselevel</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Boolean. True if used in Levellistdrawable</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><padding></span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">the distance between the content and the view boundary</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:left</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The left padding distance.</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:top</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The top padding distance.</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:right</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The right padding distance.</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:bottom</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. Bottom padding distance.</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><size></span></span> <span style="font-size: 16px;">the <span style="font-size: 16px;">size of this shape. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:height</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The height of this shape. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:width</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The width of this shape. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">note: by default, This shape is scaled to be proportional to the size of the container in which he is located. When you use this shape in a imageview, you can use android:scaletype= "center" to limit this scaling. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><solid></span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">fill the solid color of this shape</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:color</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Color. Color value, hexadecimal number, or a color resource</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"><stroke></span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">This shape uses a stroke that, when android:shape= "line", must be set to change the Element. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:width</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The thickness of the stroke. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:color</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Color. Color of strokes</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:dashgap</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. Each line is drawn at a distance of how Much. Only valid if the Android:dashwidth is Set. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:dashwidth</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Dimension. The length of one line per DRAW. Only valid if the ANDROID:DASHGAP is Set. </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Android:dashgap and Android:dashwidth set this line to be dashed, where Android:dashwidth denotes '-' the width of such a dash, android:dashgap represents the distance between the spaces, </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Use someone Else's section of Code:</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;">Button_bg.xml</span></span> <pre><span style="font-size: 16px;"><?xml version= "1.0" encoding= "utf-8"? ><shape xmlns:android= "http://schemas.android.com/apk/res/android" > <!--<solid android:color= "#ff9d77"/> <!--define The color value of the fill--<!--stroke-- <<span style="color: #000000;"><span style="color: #000000;">Stroke Android:width</span></span>= "2dp"<span style="color: #000000;"><span style="color: #000000;">Android:color</span></span>= "#fad3cf"/> <!--defines The width of the stroke and the color value of the stroke-<!--rounded corners--<<span style="color: #000000;"><span style="color: #000000;">Corners Android:bottomleftradius</span></span>= "5dp"<span style="color: #000000;"><span style="color: #000000;">Android:bottomrightradius</span></span>= "5dp"<span style="color: #000000;"><span style="color: #000000;">Android:topleftradius</span></span>= "5dp"<span style="color: #000000;"><span style="color: #000000;">Android:toprightradius</span></span>= "5dp"/> <!--set radius of four corners-<!--interval--<<span style="color: #000000;"><span style="color: #000000;">padding Android:bottom</span></span>= "10dp"<span style="color: #000000;"><span style="color: #000000;">Android:left</span></span>= "10dp"<span style="color: #000000;"><span style="color: #000000;">Android:right</span></span>= "10dp"<span style="color: #000000;"><span style="color: #000000;">Android:top</span></span>= "10dp"/> <!--set The interval of each direction-</shape><span style="color: #000000;"><span style="color: #000000;">Copy the code button_pressed_bg.xml the following: copy code</span></span><?xml version= "1.0" encoding= "utf-8"? ><shape xmlns:android= "http://schemas.android.com/apk/res/android" > <!--gradients--<<span style="color: #000000;"><span style="color: #000000;">Gradient Android:endcolor</span></span>= "#FFFFFF"<span style="color: #000000;"><span style="color: #000000;">Android:gradientradius</span></span>= "50"<span style="color: #000000;"><span style="color: #000000;">Android:startcolor</span></span>= "#ff8c00"<span style="color: #000000;"><span style="color: #000000;">Android:type</span></span>= "radial"/> <!--strokes--<<span style="color: #000000;"><span style="color: #000000;">Stroke Android:dashgap</span></span>= "3dp"<span style="color: #000000;"><span style="color: #000000;">Android:dashwidth</span></span>= "5dp"<span style="color: #000000;"><span style="color: #000000;">Android:width</span></span>= "2dp"<span style="color: #000000;"><span style="color: #000000;">Android:color</span></span>= "#dcdcdc"/> <!--rounded corners-<corners android:radius= "5dp"/> <!--interval--<<span style="color: #000000;"><span style="color: #000000;">padding Android:bottom</span></span>= "10dp"<span style="color: #000000;"><span style="color: #000000;">Android:left</span></span>= "10dp"<span style="color: #000000;"><span style="color: #000000;">Android:right</span></span>= "10dp"<span style="color: #000000;"><span style="color: #000000;">Android:top</span></span>= "10dp"/> </shape></span></pre> <p><p></p></p> <span style="font-size: 16px;"><span style="font-size: 16px;">How to use, look at the following code:</span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <pre><pre><span style="font-size: 16px;"><?xml version= "1.0" encoding= "utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:drawable=" @drawable/button_pressed_bg "android:state_pressed=" true "></ item> <item android:drawable= "@drawable/button_bg" ></item></span></pre></pre> <p><p></p></p> <span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <span style="font-size: 16px;"><span style="font-size: 16px;"></selector></span></span> </dd> </dl><span style="font-size: 16px;"><span style="font-size: 16px;"> </span></span> <dl> <dl> <dd></dd> </dl> </dl> <dl class="box_Nsc"> <dl class="box_Nsc"> <dd class="lcopy"> <span style="font-size: 16px;"> </span> </dd> </dl> </dl><p><p>Android Shape Usage Summary</p></p></span>
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