I am rotating a FrameLayout which contains an Imageview with image.When I add another Imageview on that rotated FrameLayout than the added imageview also get rotates by default as usual.
To prevent this as I need the added ImageView not to be rotated,I rotate that ImageView at the reverse angle from FrameLayout.
I am rotating FrameLayout using below code:
(1)Rotate:
float angle = mainFrm.getRotation();
if (angle == 0) {
angle = 360;
}
angle = angle - 90;
mainFrm.setRotation(angle);
(2)Flip Vertical
float angle = mainFrm.getRotationX();
if (angle == 0) {
angle = 360;
}
angle = angle - 180;
mainFrm.setRotationX(angle);
(3)Flip Horizontal
float angle = mainFrm.getRotationY();
if (angle == 0) {
angle = 360;
}
angle = angle - 180;
mainFrm.setRotationY(angle);
I am rotating ImageView using following code:
if(mainFrm.getRotation()!=0)
{
iv.setRotation(-(mainFrm.getRotation()));
}
if(mainFrm.getRotationX()!=0)
{
iv.setRotationX(-(mainFrm.getRotationX()));
}
if(mainFrm.getRotationY()!=0)
{
iv.setRotationY(-(mainFrm.getRotationY()));
}
Now the issue I am facing is when I first rotate frame(270 degree),then flip it vertically(180 degree) and after add an ImageView to that rotated frame it rotates the ImageView as well.
Here I am attaching images as well. This is the issue
I need solution like this
Any help/suggestions will be highly appreciated.
Thanks in advance
My Framelayout is like..
<FrameLayout android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#33ffff">
<ImageView android:id="@+id/image1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher"/>
<ImageView android:id="@+id/image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="@drawable/ic_launcher"/>
</FrameLayout>
and my java code is,
mFrame = (FrameLayout) findViewById(R.id.frame);
mImage1 = (ImageView) findViewById(R.id.image1);
mImage2 = (ImageView) findViewById(R.id.image2);
float angle = mFrame.getRotation();
if(angle == 0) {
angle = 180;
}
mFrame.setRotation(angle);
mImage2.setRotation(-angle);
Hope this will help you...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.