在android中设置ImageButton动画?
我对android中的动画(以及其他几乎所有的东西)真的很陌生。有没有一种方法可以设置ImageButton的动画?我只是想偶尔旋转一下按钮。就这些。有什么帮助吗 谢谢。试试这个代码片段在android中设置ImageButton动画?,android,animation,imagebutton,Android,Animation,Imagebutton,我对android中的动画(以及其他几乎所有的东西)真的很陌生。有没有一种方法可以设置ImageButton的动画?我只是想偶尔旋转一下按钮。就这些。有什么帮助吗 谢谢。试试这个代码片段 rotate.xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <rotate android:fromD
rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:duration="1000" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:startOffset="0"
android:toDegrees="360" />
rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="0"
android:duration="1000" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:startOffset="0"
android:toDegrees="360" />
收到一个
java.lang.ClassCastException:android.view.animation.AnimationSet
错误,在这一行:`RotateAnimation ranim=(RotateAnimation)AnimationUtils.loadAnimation(this,R.anim.rotate)`有什么帮助吗?我完全是动画新手..:(我认为线条应该使用动画,而不是旋转动画。另外,如果我希望圆形imagebutton围绕自身旋转,该怎么办?如果imagebutton的填充是均匀的,这很好。谢谢。