我有ImageButton與圖像。我想旋轉的唯一圖像。
不喜歡這樣的: rotating buttonAndroid。的ImageButton。如何旋轉按鈕上的圖像。不是整個按鈕
這就是我:
<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>
java代碼:
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或矩陣或任何其他辦法?
是你的代碼旋轉整個按鈕? –
是的,這是它現在的樣子:https://i.stack.imgur.com/NcVwv.gif –