繁体   English   中英

在android imageview中旋转图像

[英]rotate image in android imageview

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

有人可以用代码plz帮我吗?

谢谢

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

<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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM