rotate ImageView - Android User Interface

Android examples for User Interface:ImageView

Description

rotate ImageView

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.widget.ImageView;

public class Main {
    public static void rotateImageView(Context context,
            ImageView imageView, float angle, int imageId) {
        Bitmap myImg = BitmapFactory.decodeResource(context.getResources(),
                imageId);//w w w  .j  av  a2 s .  c  om

        Matrix matrix = new Matrix();
        matrix.postRotate(angle);

        Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(),
                myImg.getHeight(), matrix, true);

        imageView.setImageBitmap(rotated);
    }
}

Related Tutorials