-2

I want to show image in rectangle tilted to 90 deg. How i can do this ?

enter image description here

In this frame i want to show image

please give me some solutions.

Thanks.

vjdhama
  • 4,878
  • 5
  • 33
  • 47
user3083119
  • 29
  • 1
  • 7

4 Answers4

3

you could create a 45d animation and apply it to your ImageView, like this:

    ImageView image= (ImageView)findViewById(R.id.imageView);
    // Create 45d animaion
    Animation an = new RotateAnimation(0.0f, 45f, image.getPivotX(), image.getPivotY());

    // Set the animation's parameters
    an.setDuration(1);               
    an.setRepeatCount(0);                
    an.setRepeatMode(Animation.REVERSE); 
    an.setFillAfter(true);               

    // Aplly animation to image
    image.setAnimation(an);
Mouad EL Fakir
  • 3,609
  • 2
  • 23
  • 37
1

With API >= 11

mImageView.setRotation(angle) 

Another Method :

ImageView img = (ImageView)findViewById(R.id.yourImageViewId);
Options o = getSize(this, R.drawable.yourImage);
Matrix m = new Matrix();
m.postRotate(angle, o.outWidth/2, o.outHeight/2);
img.setScaleType(ScaleType.MATRIX);
img.setImageMatrix(m);
vjdhama
  • 4,878
  • 5
  • 33
  • 47
0

Use the below method.

public static Bitmap rotate(Bitmap src, float degree) {
    // create new matrix
    Matrix matrix = new Matrix();
    // setup rotation degree
    matrix.postRotate(degree);

    // return new bitmap rotated using matrix
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}
Sunny Garg
  • 1,073
  • 1
  • 6
  • 13
0

For All APIs Place ImageView in your Layout XML, and set An Animation for it in the onCreate() of your Activity like that :

float rotationDegree = -45; //You can change if you need.
        Animation anim = new RotateAnimation(0,rotationDegree);
        anim.setFillAfter(true);
        imageView.startAnimation(anim);