5.3.9. Determining the Screen Size

In this app, we display the Menu only when the app is running on a phone-sized device or when it’s running on a tablet in portrait orientation (Section 5.5.4). To determine this, we’ll use Android’s WindowManager (package android.view) to obtain a Display object that contains the display’s current width and height. This changes with the device’s orientation—in portrait orientation, the device’s width is less than its height.

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.