Reprint this article please indicate the source: http://blog.csdn.net/qq_32059827/article/details/52203347 Click to open the link
Before customizing the progress bar, learn about the use of shape.
First, create a new drawble directory below the Res directory (it will be simple if you customize the state selector)
Second, create a new Android.xml file, Find shape, click Finish
We can see that the shape attribute is not many, as follows:
Now step through the common use of attributes:
1, <corners/> means "angle", which means rounded corners
(1), Radius: Represents the radius android:radius= "5dip", specifying a fillet radius of 5dip
2. <gradient/>: Indicates a color gradient. Radioactivity changes
Test the top two attribute characteristics:
The Drawable/shapetest.xml code is as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" > <corners android:radius= "5dip" > </corners> <gradient android:endcolor= "# 00ff00 " android:startcolor=" #ff0000 "/></shape>
Introduce shape.xml in the layout file of the test activity:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:layout_width=" match_parent " android:layout_height=" Match_parent " tools:context= ". Mainactivity "> <textview android:textsize=" 22SP " android:background=" @drawable/shapetest " android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "@string/ Hello_world "/></relativelayout>
This displays the slice:
All right. Then look at some of the properties behind shape:
3, <padding/> Represents the inner spacing, and the layout file in the padding effect, do not introduce.
4, <size/> Ibid, can be directly in the layout file settings
5, <solid/> Fixed colors, set this primary color, the radiation color will not work
6, <stoke/> Reorganization pieces add border line, look at setting this property, change why it looks like:
<stroke android:width= "1dip" android:color= "#0000ff" android:dashwidth= "5dip" android:dashgap= " 5dip "/>
respectively: The outer border color width is 1, the color is blue, the dash length is 5, and the spacing between dashes is 5. The effect is as follows:
The basic usage of shape here has been introduced. Finish the basic usage of shape, complete the case of a custom color progress bar in the 17th session of Android simple combat series
Android Beginner Tutorial: Basic usage of shape