-
扫描动画
RotateAnimation anim = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); anim.setDuration(1000);//间隔时间 anim.setRepeatCount(Animation.INFINITE);//无限循环 anim.setInterpolator(new LinearInterpolator());//匀速循环,不停顿 ivScanning.startAnimation(anim);
-
自定义进度条样式
1. 查看android系统对Progressbar样式的定义 开发环境\platforms\android-16\data\res\values\styles.xml,搜索Widget.Holo.ProgressBar.Horizontal->progress_horizontal_holo_light 2. 拷贝xml文件,修改成自己的图片 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@android:id/background" android:drawable="@drawable/security_progress_bg"/> <item android:id="@android:id/secondaryProgress" android:drawable="@drawable/security_progress"> </item> <item android:id="@android:id/progress" android:drawable="@drawable/security_progress"> </item> </layer-list> 3. 将xml文件设置给Progressbar <ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:progress="50" android:layout_marginTop="5dp" android:progressDrawable="@drawable/custom_progress" />
-
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<shape
android:innerRadius="12dp"
android:shape="ring"
android:thickness="3dp"
android:useLevel="false" >
<gradient
android:centerColor="#3f00"
android:endColor="#f00"
android:startColor="#fff" />
</shape>
</rotate>
<ProgressBar
android:id="@+id/pb_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/custom_progress"
android:visibility="invisible" />