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

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.


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).

Tags:

Android