Android: Rotate image in imageview by an angle

前端 未结 25 3077
野趣味
野趣味 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:22

    try this on a custom view

    public class DrawView extends View {
    
    
        public DrawView(Context context,AttributeSet attributeSet){
            super(context, attributeSet);
        }
    
        @Override
        public void onDraw(Canvas canvas) {
            /*Canvas c=new Canvas(BitmapFactory.decodeResource(getResources(), R.drawable.new_minute1)    );
    
            c.rotate(45);*/
    
            canvas.drawBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.new_minute1), 0, 0, null);
            canvas.rotate(45);
        }
    }
    

提交回复
热议问题