Arpit Patel
Arpit Patel

Reputation: 1571

how to rotate multiple images in android with overlay on eachother in XML code?

I want to display the roating images like the below shown in image one by one. How can i code in xml. I could not able to rotate image using android:rotation="20". I have to display the images like shown in image with the one on one from left to right.

enter image description here

Upvotes: 0

Views: 987

Answers (3)

Roadies
Roadies

Reputation: 3329

public class Rotate {

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);
}

}

Upvotes: 1

Yicanis
Yicanis

Reputation: 328

Take a look at this code

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
        android:fromDegrees="90"
        android:toDegrees="90"
        android:pivotX="50%"
        android:pivotY="50%"
        android:drawable="@drawable/image">
</rotate>

Make sure your android:fromDegrees is correct.

Upvotes: 0

jay
jay

Reputation: 292

It will be better to write method, and write in it RotateAnimation code, and pass the parameters accordingly to rotate each and every image.

Upvotes: 0

Related Questions