How to rotate the screen to landscape (or portrait) in a programmable way? I try to make it independent when the user rotates the screen.
Is it possible?
Thanks in advance.
You can try with the example below ...
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { // You can set the value initially by // ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED. Once set it // retains it value. The View will be rendered in the specified // orientation using the code below. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
Try the following:
Activity.setRequestedOrientation()
with these parameters:
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
Check this box for future reference.