Skip to content Skip to sidebar Skip to footer

Force Android Screen Orientation Depending On Screen Size

I am writing an application that allows users to select various things on the screen. On large 10 inch screens this looks best in landscape so I force landscape in the manifest fil

Solution 1:

To find out if the device is a 7, 8 or 10 inches tablet, you can check this.

One way you can manipulate the device orientation is in every activity, after onCreate(), like this:

// set the orientation of the deviceif(isTabletWith10Inches) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

Post a Comment for "Force Android Screen Orientation Depending On Screen Size"