Large screen cookbook

Android provides all the ingredients for five-star large screen apps. The recipes in this cookbook select and combine choice ingredients to solve specific development problems. Each recipe includes best practices, quality code samples, and step-by-step instructions to help you become a large screen top chef.

Star ratings

The recipes are star rated based on how well they align with the Large screen app quality guidelines.

Five-star rating Meets the criteria for Level 1, Large screen differentiated
Four-star rating Meets the criteria for Level 2, Large screen optimized
Three-star rating Meets the criteria for Level 3, Large screen ready
Two-star rating Provides some large screen capabilities, but falls short of the large screen app quality guidelines
One-star rating Meets the needs of a specific use case, but doesn't properly support large screens

Restrict app orientation on phones but not on large screen devices

Two-star rating

Your app works great on phones in portrait orientation, so you've restricted the app to portrait only. But you see an opportunity to do more on large screens in landscape orientation.

How can you have it both ways—restrict the app to portrait orientation on small screens, but enable landscape on large?

Best practices

The best apps respect user preferences such as device orientation.

The Large screen app quality guidelines recommend that apps support all device configurations, including portrait and landscape orientations, multi-window mode, and folded and unfolded states of foldable devices. Apps should optimize layouts and user interfaces for different configurations, and apps should save and restore state during configuration changes.

This recipe is a temporary measure—a pinch of large screen support. Use the recipe until you can improve your app to provide full support for all device configurations.


  • screenOrientation: App manifest setting that enables you to specify how your app responds to device orientation changes
  • Jetpack WindowManager: Library that enables you to determine the size and aspect ratio of the app window; backward compatible to API level 14
  • Activity#setRequestedOrientation(): Method with which you can change the app orientation at runtime



Enable the app to handle orientation changes by default in the app manifest. At runtime, determine the app window size. If the app window is small, restrict the app's orientation by overriding the manifest orientation setting.

1. Specify orientation setting in the app manifest

Set the screenOrientation element of the app manifest to fullUser. If the user has not locked sensor-based rotation, your app will support all device orientations.


2. Determine screen size

With the manifest set to support all user-permitted orientations, you can specify app orientation programmatically based on screen size.

Use the Jetpack WindowManager library's WindowMetricsCalculator#computeMaximumWindowMetrics() method to obtain the device screen size as a WindowMetrics object. The window metrics can be compared to window size classes to decide when to restrict orientation.

Windows size classes provide the breakpoints between small and large screens. The smaller dimension (width or height) of a typical phone is less than 600dp; the smaller dimension of tablets and large screen foldables, greater than 600dp.

Use the breakpoint dp values to determine the screen size:


/** Determines whether the device has a compact screen. **/
fun compactScreen(): Boolean {
    val screenMetrics = WindowMetricsCalculator
    val shortSide = min(screenMetrics.bounds.width(),
    return shortSide / resources.displayMetrics.density < 600


/** Determines whether the device has a compact screen. **/
public boolean compactScreen() {
    WindowMetrics screenMetrics = WindowMetricsCalculator
    int shortSide = Math.min(screenMetrics.getBounds().width(),
    return shortSide / getResources().getDisplayMetrics().density < 600;
  • The above examples are implemented as methods of an activity; and so, the activity is dereferenced as this in the argument of computeMaximumWindowMetrics().
  • The computeMaximumWindowMetrics() method is used instead of computeCurrentWindowMetrics() because the app can be launched in multi-window mode, which ignores the screen orientation setting. There's no point in determining the app window size and overriding the orientation setting unless the app window is the entire device screen.

See WindowManager for instructions about declaring dependencies to make the computeMaximumWindowMetrics() method available in your app.

3. Override app manifest setting

When you've determined that the device has compact screen size, you can call Activity#setRequestedOrientation() to override the manifest's screenOrientation setting:


override fun onCreate(savedInstanceState: Bundle?) {
    requestedOrientation = if (compactScreen())


protected void onCreate(Bundle savedInstance) {
    if (compactScreen()) {
    } else {

By adding the logic to the onCreate() method, you're able to obtain the screen size and override the orientation setting whenever the activity is created, such as after a device rotation or when a foldable device is folded or unfolded.


Your app should now remain in portrait orientation on small screens regardless of device rotation. On large screens, the app should support landscape and portrait orientations.

Additional resources

For help with upgrading your app to support all device configurations all the time, see the following: