Android custom ProgressBar implementation

 The custom ProgressBar introduced here is mainly a dynamic circular progress bar, which is mainly used for the waiting process of a long-term operation. For example, a user clicks a button to initiate a network request to obtain relevant data and display it on the interface. This process is a long-term operation. The time from start to finish cannot be fixed. It is related to network conditions and server response waiting factors. During this process, there must be a progress bar effect to tell the user that they need to wait.

The style definition of the progress bar: (drawable/rotate_progress.xml)

<rotate xmlns:android="http://schemas.android.com/apk/res/android"      
    android:fromDegrees="0"      
    android:pivotX="50%"      
    android:pivotY="50%"       
    android:toDegrees="360"
    android:duration="2000"
    >            
    <shape           
        android:innerRadiusRatio="3"          
        android:shape="ring"           
        android:thicknessRatio="8"          
        android:useLevel="false" >                
        <gradient               
            android:centerY="0.50"              
            android:endColor="#f84e4e"              
            android:startColor="#ffffff"         
            android:type="sweep"               
            android:useLevel="false" />       
</shape>        
</rotate>

 How to use:

<ProgressBar
                android:id="@+id/gif"
                android:layout_width="35dp"
                android:layout_height="35dp"
                android:layout_gravity="center_horizontal"
                android:background="@null"
                android:indeterminate="false"
                android:indeterminateDrawable="@drawable/rotate_progress"
                />

 Welcome to download my software experience: http://android.myapp.com/myapp/detail.htm?apkName=com.yln.history

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326780650&siteId=291194637