在android imageview中旋转图像

问题描述:

我想构建一个应用程序,我通过(ImageView)显示图像。
和应用程序中的文本框。
我想每秒连续旋转图像大约10度。当图像旋转时,文本框应显示图像旋转的次数。
我试图旋转图像,但每次应用程序崩溃或没有出现在屏幕上。

I want to build an application where, I have an image displayed via (ImageView). and a textbox in the application. I want to rotate the image in continuously for about 10 degree for every one second. when the image rotates, the textbox should display the number of times the image is rotated. I tried rotating the image but every time the application crashes or doesn't show up in the screen.

有人可以帮我解决代码问题吗?

Can someone help me with the code plz ??

谢谢

使用此代码创建动画旅馆res / anim

Create animation inn res/anim with this code

<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:duration="36000" />

并在您的活动中:

Animation rotate = AnimationUtils.loadAnimation(this, R.anim.rotate);
findViewById(R.id.yourImageId).startAnimation(rotate);
rotate.reset();
rotate.start();