旋转对话框
16lz
2021-01-23
<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>{@Overrideprotected void onProgressUpdate(Integer... values) {super.onProgressUpdate(values);int pos = values[0];progressBar.setProgress(pos);}@Overrideprotected 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;}@Overrideprotected void onPostExecute(Void result) {super.onPostExecute(result);}}
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer