把一个计时器上的图像旋转? [英] Putting a timer on image rotation?
本文介绍了把一个计时器上的图像旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Android(2.3.3),这可能使图像的旋转不会瞬间?
On Android(2.3.3), is it possible to make the rotation of an image not be instant?
我用过,从这里 的code例如:
The code example I used, from here:
img=(ImageView)findViewById(R.id.ImageView01);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.refresh);
// Getting width & height of the given image.
int w = bmp.getWidth();
int h = bmp.getHeight();
// Setting post rotate to 90
Matrix mtx = new Matrix();
mtx.postRotate(90);
// Rotating Bitmap
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
BitmapDrawable bmd = new BitmapDrawable(rotatedBMP);
img.setImageDrawable(bmd);
这旋转的瞬间,我想使旋转可见。这有可能在Android中,或者是说一个闪光的东西?
This rotation is instant, and I'd like to make the rotation visible. Is that possible in Android, or is that a Flash thing?
推荐答案
您应该使用的 ViewAnimation 您的ImageView。像这样的东西是你所需要的:
You should use a ViewAnimation on your imageview. Something like this is what you need:
在您的RES /动画文件夹:
in your res/anim folder:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0" android:toDegrees="90"
android:duration="2000" android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:startOffset="1000"
/>
它应用到你的观点:
Apply it to your view:
img.startAnimation(AnimationUtils.loadAnimation(context, R.anim.rotate));
您必须探索不同的选择和对自己:)结果属性
下面是更多的一些信息的链接。
You'll have to explore the different options and attributes on your own :)
Here's a link to some more info.
这篇关于把一个计时器上的图像旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文