Hi, Habr! I present to you the translation of the article by Fred Chung's
Tuning article.
In recent months, there is a growing tendency for phone manufacturers to introduce new devices with a long screen (more than 16: 9), many of which have rounded corners. Pixel 2 XL and Huawei Mate 10 Pro are just two of many examples. These screen features can bring users an impressive experience, but they draw attention to applications and games that do not use a long format screen on new devices. Therefore, it is important for developers to optimize such screens. Let's take a look at the appropriate support provided by the Android OS.
Optimized for screens with a long aspect ratio
Most applications using standard user interface widgets will most likely run on these devices. The
Android documentation specifies methods for flexible working on screens of different sizes. However, some games and applications with user interfaces may run into problems due to incorrect assumptions about certain proportions. We share several typical problems that developers face, so you can look at those that apply to you:
')
- Certain sides of the screen are cropped. Because of this, any graphic or user interface elements in the affected areas appear incomplete.
- Touch targets are shifted away from user interface elements (for example, buttons). Users may confuse items
- In the full-screen mode on the rounded corners of the devices, any user interface elements that are very close to the corners may be located outside the curved corner viewing area. Imagine that clicking on the “Purchase” button of a commercial application is difficult? We recommend referring to material design recommendations , leaving 16dp side margins in layouts.
If a responsive user interface is not really appropriate for your situation, in extreme cases, declare an explicit maximum supported aspect ratio as follows. On devices with a higher aspect ratio, the application will be shown in compatibility mode with the system mailbox. Keep in mind that some device models provide redefinition for users to make the application run in full-screen compatibility mode, so be sure to test this optimization method in this situation.
Targets API level 26 or higher: use attributes
android: maxAspectRatio
Targets API level 25 or lower: use metadata
android.max_aspect
Please note that the maximum aspect ratio values will be observed only if your actions do not support
resizableActivity
For more information, see the
documentation .
The system mailboxes in the application are used when the declared maximum aspect ratio is smaller than the device screen.
Consider using parallel actions.
Devices with a long aspect ratio provide even more options for using multiple windows, which can improve user productivity. Starting with Android 7.0, the platform offers a standard way for developers to implement multi-window mode on supported devices, as well as to drag and drop data between active windows. See the
documentation for details.
Testing is crucial. If you do not have access to one of the devices with a long screen, be sure to check on the emulator the necessary screen properties and resolutions, which are described in the
emulator documentation .
We know that you want to please your users with devices with a long screen. With a few steps, you can ensure that your applications and games take full advantage of these devices!