旋转对话框

<ProgressBar
        android:layout_width="wrap_content"
        android:interpolator="@android:anim/linear_interpolator"
        style="@style/ProgressBar"
        android:layout_height="wrap_content" />

 

style:

 

<?xml version="1.0" encoding="UTF-8"?>
<resources>
	<style name="ProgressBar" parent="@android:style/Widget.ProgressBar.Large">
        <item name="android:indeterminateOnly">true</item>
        <item name="android:indeterminateDrawable">@anim/cycle_anim</item>
    </style>
</resources>

 

 

anim  cycle_anim

 

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
	android:drawable="@drawable/circle_drawable" 
	android:pivotX="50%" 
	android:pivotY="50%"
	android:fromDegrees="0" 
	android:toDegrees="360" />

 

 

<ProgressBar 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="6dip"
        android:layout_centerVertical="true"
        android:id="@+id/loading"       android:indeterminateDrawable="@drawable/progress_bar_vertical_style"/>

progress_bar_vertical_style

 

<?xml version="1.0" encoding="utf-8"?>  
<animated-rotate  
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:pivotX="50%" android:pivotY="50%"      
 android:fromDegrees="0"    
 android:drawable="@drawable/loading_circle"
 android:toDegrees="360">  
</animated-rotate>  

 

 

class ScanTask extends AsyncTask<Void, Integer, Void>{
		
		
		@Override
		protected void onProgressUpdate(Integer... values) {
			super.onProgressUpdate(values);
			
			int pos = values[0];
			progressBar.setProgress(pos);
		}

		@Override
		protected Void doInBackground(Void... params) {
			progressBar.setMax(100);
			for(int i= 0 ;i< 100;i++ ){
				publishProgress(i);
				try {
					Thread.sleep(500);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			return null;
		}

		@Override
		protected void onPostExecute(Void result) {
			super.onPostExecute(result);
		}
	}

 

你可能感兴趣的:(对话框)