setRequestedOrientation(0);
or
setRequestedOrientation(1);
horizontal (landscape) - 0 vertical (potrait) - 1
You can try this.
Or you can try it on your way. In the onCreate method of this activity, which orientation you want to change, put this code in this. This will change the orientation of the layout.
source
share