To define the ProgressBar method by using the Indeterminatedrawable property:
<ProgressBar android:id="@+id/pb" android:layout_width="30dp" android:layout_height="30dp" android:layout_centerVertical="true" android:indeterminateDrawable="@drawable/loading" />
There are several ways in which the loading.xml can be:
1.animation-list, consisting of a bunch of continuous images:
<?xml version= "1.0" encoding= "UTF-8"?> <animation-list android:oneshot="false"xmlns:android="http// Schemas.android.com/apk/res/android "> <item android:duration=" android:drawable="@drawable/load _1 " /> <item android:duration=" " " android:drawable="@drawable/load_2 " /> <item android:duration=" android:drawable="@drawable/load_3 " /> <item android:duration=" android:drawable="@drawable /load_4 " /> <item android:duration=" " " android:drawable="@drawable/load_5 " /> <item android:duration=" android:drawable="@drawable/load_6 " /> <item android:duration=" android:drawable="@drawable /load_7 " /> <item android:duration=" " " android:drawable="@drawable/load_8 " /> </animation-list>
2.layer-list/rotate, the continuous rotation of a picture is achieved by:
<?xml version="1.0" encoding="utf-8"?
> <layer-list xmlns:android="Http://schemas.android.com/apk/res/android" > <item> <rotate android:drawable="@drawable/loading" android:fromdegrees= "0.0" android:pivotx="50.0%" android:pivoty="50.0%" android: Todegrees=" /> " </Item> </layer-list>
3. Define a circular shape and color rotation:
<rotate xmlns:android = "http://schemas.android.com/apk/res/android" android:fromdegrees = "0" android:pivotx = Android:pivoty = "50%" android:todegrees = "the" ; <shape android: Innerradiusratio = "3" android:shape =< Span class= "Hljs-value" > "ring" android:thicknessratio =" " android:uselevel =" false "
; <gradientandroid:centercolor= "#FFFFFF"android:centery="0.50" Android:endcolor="#1E90FF"android:startcolor= "#000000"android: Type="Sweep"android:uselevel="false" /> </shape> </rotate>
In the use of the process found that the first form in 6.0 below the system perfect execution, but in 6.0 and above the system can not be displayed, if you encounter this problem can choose other ways to do! The reason for not showing is unknown. It could be a 6.0 bug.
。。
ProgressBar the Indeterminatedrawable attribute on Android 6.0 issue