须要保持界面风格一致,告诉用户正在加载,用animation实现,很简单 java
<set xmlns:android="http://schemas.android.com/apk/res/android"> android
<rotate 动画
android:interpolator="@android :anim/cycle_interpolator" this
android:pivotX="50%" spa
android:pivotY="50%" .net
android:fromDegrees="0" rest
android:toDegrees="+360" xml
android:duration="2000" get
android:repeatMode="restart" animation
android:repeatCount="-1"/>
</set>
设置上两个参数
repeatMode 开启循环模式
repeatCount 设置为-1时表示无限循环
注意:上面xml中定义interpolator会出现转一圈后停顿一下。这个时候我查到了Android中有这么一个类LinearInerpolator:这个类是Inerpolator的子类,是实现匀速动画的关键。可是不能经过XML中的那个android:interpolator属性去设置,必须在java代码中去实现:
Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate_loading_anim); animation.setInterpolator(new LinearInterpolator());