80,360
社区成员
发帖
与我相关
我的任务
分享
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--自定义动画-->
<rotate
android:duration="1000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="359"
android:repeatCount="-1"/>
</set>
repeatCount等于-1就代表无限循环,至于你说的停顿是因为默认动画效果是先慢中间速度快最后又慢速,需要设置匀速动画,需要在代码中设置
LinearInterpolator lir = new LinearInterpolator();
rotate.setInterpolator(lir);
img_load_animation.startAnimation(rotate);
java代码
public class MainActivity extends Activity {
ImageView img_load_animation;
Animation rotate;
Handler mhandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img_load_animation=(ImageView) findViewById(R.id.img_load_animation);
rotate=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.load);
img_load_animation.startAnimation(rotate);
}
}
[code=xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
自定义动画
<rotate
android:duration="60000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="21600"
android:repeatCount="0"/>
</set>
][/code]