SoFunction
Updated on 2025-04-05

Android Development Manual Shape Attributes and Subproperties Instructions

😜shape attribute detailed explanation

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:andro
    android:innerRadius="30dp"
    android:innerRadiusRatio="2"
    android:shape="ring"
    android:thickness="2dp"
    android:thicknessRatio="3"
    android:useLevel="false">
</shape>
  • android:shape="line"  The shape of shape, default is rectangle, can be set as rectangle, oval, linear shape, and ring.
  • android:innerRadius  Dimension, radius of the inner ring, only ring shape available.
  • android:innerRadiusRatio  floating point type, the radius of the inner ring is represented by the width ratio of the ring. For example, the width of the ring is 50 and the ratio is 2.5, then the radius of the inner ring is 20
  • android:thickness  Dimension, ring thickness
  • android:thicknessRatio floating point type, the thickness of the ring is expressed in the width ratio of the ring, similar to innerRadiusRatio
  • android:useLevel  boolean value, sometimes it must be added to make it effective, and it will make it effective if you write it

😜 sub-properties detailed explanation

&lt;corners    //Define rounded corners    android:radius="10dp"      //All rounded corner radii, example: 10dp    android:topLeftRadius="10dp"   //The rounded corner radius in the upper left corner, example: 10dp    android:topRightRadius="10dp"  //The rounded corner radius in the upper right corner, example: 10dp    android:bottomLeftRadius="10dp"    //The radius of the rounded corner at the lower left corner, example: 10dp    android:bottomRightRadius="10dp" /&gt;    //The rounded corner radius in the lower right corner, example: 10dp&lt;solid android:color="#ffff00" /> //There is only one color, just set the fill color.&lt;gradient  
    android:type="linear"   //There are 3 gradient types in total, linear gradient (default linear)/radial gradient (radial)/sweep gradient (sweep)    android:angle="0"     //The gradient angle must be multiples of 45, 0 is from left to right, 90 is from top to bottom, only the linear gradient takes effect    android:centerX="0.2"     //The equivalent position of the gradient center X, with a range of 0~1, is mostly used for radiation gradient    android:centerY="0.1"     //The equivalent position of the gradient center Y, the range is 0~1, and is mostly used for radiation gradient    android:startColor="#ff0000" //The color of the gradient start point android:centerColor="#ffff00" //The color of the gradient middle point is between the beginning and end points android:endColor="#00ff00" //The color of the gradient end point android:gradientRadius="10" //The radius of the gradient can only be used when the gradient type is radial    android:useLevel="false" /&gt;  //Attributes are not usually used.  This property is used to specify whether to use the shape as a LevelListDrawable, and the default value is false.&lt;stroke     
    android:width="dimension"    //Indicate the width of the stroke    android:color="#00ff00" //Denotes the color of the stroke, such as green android:dashWidth="8dp" //The width of the dotted line, when the value is 0, it is the solid line, example 8dp width    android:dashGap="1dp" /&gt;   //The interval of dotted lines,Example interval1dp

The above is the detailed content of the shape attributes and sub-properties instructions for Android development manual. For more information about the shape attribute sub-properties of Android development, please pay attention to my other related articles!