Android: Rotate image in imageview by an angle

前端 未结 25 3071
野趣味
野趣味 2020-11-22 06:35

I am using the following code to rotate a image in ImageView by an angle. Is there any simpler and less complex method available.

ImageView iv = (ImageView)f         


        
25条回答
  •  佛祖请我去吃肉
    2020-11-22 07:05

    Rather than convert image to bitmap and then rotate it try to rotate direct image view like below code.

    ImageView myImageView = (ImageView)findViewById(R.id.my_imageview);
    
    AnimationSet animSet = new AnimationSet(true);
    animSet.setInterpolator(new DecelerateInterpolator());
    animSet.setFillAfter(true);
    animSet.setFillEnabled(true);
    
    final RotateAnimation animRotate = new RotateAnimation(0.0f, -90.0f,
        RotateAnimation.RELATIVE_TO_SELF, 0.5f, 
        RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    
    animRotate.setDuration(1500);
    animRotate.setFillAfter(true);
    animSet.addAnimation(animRotate);
    
    myImageView.startAnimation(animSet);
    

提交回复
热议问题