在android imageview中旋转图像 [英] rotate image in android imageview

查看:182
本文介绍了在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();

这篇关于在android imageview中旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆