6

Part of my application requires it to be compatible if somebody was looking at the screen via mirror. Does anybody know a way where I can mirror all of the text on screen? I have tried mirrorText.setLayoutDirection(View.LAYOUT_DIRECTION_RTL); but it hasn't worked. Thank you

Ethan
  • 1,905
  • 2
  • 21
  • 50
  • check this out: http://stackoverflow.com/questions/12398283/android-mirroring-a-view – e-shfiyut Mar 16 '16 at 18:27
  • Uh God I'm going to have to do this for every single `textView` and `Button` aren't I. Can I apply this same method to the layout as a whole? – Ethan Mar 16 '16 at 18:31
  • @user154248 - well, you could create a subclass of textview, maybe call it mirrorview, then write a method that mirrors it and derive all your textviews from mirrorview, if that helps. anyways, +1 for self-answering. – katzenhut Mar 16 '16 at 19:36

1 Answers1

18

This is very simple to accomplish. The code I used was:
Text.setScaleX(-1); Text.setScaleY(1); Text.setTranslationX(1); //To place everything back where it was originally. Hope this helps!

Ethan
  • 1,905
  • 2
  • 21
  • 50
  • is the same logic would work with `SurfaceView` ? I need to mirror a video displayed by `SurfaceView`. tried rotation and `setScale` with no luck! – Sam Jun 03 '19 at 12:04
  • Not sure @Sam, this was posted back in 2016, different World now! Make sure you are doing a translation, not rotation. – Ethan Jun 09 '19 at 15:48