Show the application only in portrait mode in Android

To show the app only in portrait, in the application tag of your manifest file of the application you need to add one more attribute. The attribute to show the app in portrait is,
Or if you don't want the entire application in portrait mode, only some screens(Activity) to be in portrait mode, then put the same tag,
to whichever activity you want in portrait mode. The activity tag will look like,
In activity class also, you can restrict to portrait mode by adding 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); in the onCreate() before calling setContentview()

Popular posts from this blog

AlarmManager and Notification in Android

Swipe Action and ViewFlipper in Android

Difference between SurfaceView and View in Android