本文介绍了Android的:由90degrees但无延迟的旋转图像的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个游戏,用户需要挖掘的ImageView在图像上旋转。在每个抽头图像在顺时针方向旋转90度。
但是,图像需要时间,从旧旋转到新的位置。这是阻碍游戏体验。我已经使用了以下内容:
I am developing a game where a user needs to tap on the image in ImageView to rotate it. On each tap image rotates by 90 degrees in clockwise direction.But image is taking time to rotate from old to new position. This is hampering the gameplay experience. I have used the following:
protected void onCreate(Bundle savedInstanceState)
{
...
...
imgview
=(ImageView)findViewById(R.id.imageView1); imgview.setOnClickListener(new OnClickListener() {
@Override public void onClick(View arg0) {
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap myImg = getBitmapFromDrawable(imgview.getDrawable());
Bitmap rotated = Bitmap.createBitmap(myImg,0,0,myImg.getWidth(),myImg.getHeight(),matrix,true);
imgview.setImageBitmap(rotated);
}
});
我想知道是否有任何的其他的方式来旋转图片
无旋转产生的任何延迟
推荐答案
我也试着做一次,但没有找到任何其他的解决办法,但使用动画。在这里,我怎么会做。
I also tried to do it once and couldn't find any other solution but using animation. Here how I'd do.
private void rotate(float degree) {
final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(0);
rotateAnim.setFillAfter(true);
imgview.startAnimation(rotateAnim);
}
这篇关于Android的:由90degrees但无延迟的旋转图像的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!