Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: is there a way to horizontally flip a layout?

Tags:

android

Is there a way to hit a button, and have the same layout view but flipped horizontally/mirrored ? (with all it's components) or the only way is to create the same layout and rearrange the components?

like image 476
user3387848 Avatar asked Mar 07 '14 22:03

user3387848


People also ask

How to flip horizontal Android?

Tap the crop icon in the bottom as it has the flip options, then tap Rotate from the newly opened toolbar. You can now tap Flip Horizontal or Flip Vertical to flip your photo.

How do you flip horizontal?

To flip an image or icon, simply: Select the object you would like to flip. Right click on that object, and select 'Flip Horizontal' or 'Flip Vertical'.

How to invert video on Android?

Open Google Photos on your Android phone, tap the Search bar. Tap Videos and choose the video you want to rotate or flip. Tap the Slide bar and tap Rotate to flip a video on Android.


2 Answers

You can flip a layout by setting the View property scaleX to -1. So View#setScaleX(1f) is normal, and View#setScaleX(-1f) is flipped (visually).

To do it pre-Honeycomb, you can use scale properties in the general Animation library. Just set the animation duration to 0 for immediate look (note, the elements will still be in the normal locations).

like image 136
DeeV Avatar answered Sep 30 '22 05:09

DeeV


You can use setRotationY(float) method to flip over the Y axis. If you would call yourView.setRotationY(180f) it would flip it horizontally. Similarly, yourView.setRotationX(180f) would flip it vertically.

Please note that it flips on a 3D space, so if you'd flip for 90f, your view will practically be invisible.

like image 40
Mert Kahraman Avatar answered Sep 30 '22 05:09

Mert Kahraman