1

I'm working on an app where two players will play on the same phone in front of each other and I rotate many things 180 degrees each turn. (few things should not rotate)

The players might use the keyboard to type some text when needed, so I need to also rotate the keyboard 180 degrees and put it in the upper side of the screen if it's the other player's turn.

How can I do that programmatically to the keyboard only?

I should also do the same when I start developing the iOS app!

M. Sherbeeny
  • 109
  • 2
  • 12

1 Answers1

2

Try: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); for rotating the screen by 180 degrees and when you want to switch back to the original view use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

sinaks
  • 76
  • 11
  • Is it possible to cancel the rotation animation ? This seems promising.. it even fixes a shadows problem as I didn't know how to make the shadows be above the views when elevated. – M. Sherbeeny Apr 24 '16 at 19:20
  • Yes, it's possible.. here's how: http://stackoverflow.com/questions/11957772/disable-default-animation-from-portrait-to-landscape/36828791#36828791 – M. Sherbeeny Apr 24 '16 at 21:55
  • the reverse orientation works fine on API 21 but not on API 19 !!? – M. Sherbeeny Apr 24 '16 at 21:56
  • This gentleman here says that this feature was introduced in API level 9 http://stackoverflow.com/a/31926128/5355581 One other thing I read on the thread was somebody mentioning to add `android:configChanges = "orientation"` to the manifest file. – sinaks Apr 24 '16 at 23:09
  • I added the configChanges but still not working on LG G2 (API 19) but working fine on Samsung S5 (API 21)! – M. Sherbeeny Apr 24 '16 at 23:28
  • May be you can first trying getting the root view of your activity by calling `View view = (View)findViewById(R.id.content)` and then use `view.setRotation(180)`. Try this and let me know if this works. – sinaks Apr 24 '16 at 23:34
  • It now works as the screenrotation was disabled on G2! Now I need to force the rotation even if the autorotation is disabled ! – M. Sherbeeny Apr 24 '16 at 23:37