I want to show image in rectangle tilted to 90 deg. How i can do this ?
In this frame i want to show image
please give me some solutions.
Thanks.
I want to show image in rectangle tilted to 90 deg. How i can do this ?
In this frame i want to show image
please give me some solutions.
Thanks.
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);
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);
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);
}
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);