【发布时间】:2017-09-21 17:49:21
【问题描述】:
我有一个带有图像的 ImageButton。我想旋转唯一的图像。
不是这样的:
rotating button
这就是我所拥有的:
<ImageButton
android:id="@+id/imageButton"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignBottom="@+id/button"
android:src="@drawable/up"
/>
动画:
<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>
爪哇代码:
public void clockwise(View view){
ImageButton image = (ImageButton)findViewById(R.id.imageButton);
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);<p>
image.startAnimation(animation);
}
我应该使用 AnimationDrawable 还是 Matrix 或任何其他方法?
【问题讨论】:
-
您的代码是否在旋转整个按钮?
-
是的,这就是现在的样子:i.stack.imgur.com/NcVwv.gif
标签: android image button rotation imagebutton