I am new to Android development. I finish my first large application, but the problem is that at the moment the application is displayed correctly only on one type of screen dimension. The application was written and tested on one device only.

Such a question, you need to impose under each density of screens mdpi hdpi xhdpi xxhdpi xxxhdpi ?
The application will only support portrait orientation and should work only on smartphones (up to about 7 inches), not on tablets. How to do it better? How to be with pictures?

I know that they definitely need to scale themselves. For example, I have a large picture 700*1500 px .

Unfortunately, it is not possible to test on different physical devices, is it possible to do all this in Genymotion . On which devices to test in the emulator. There is a possibility that something in the application will not work in the emulator as if it were on a physical device.

Share your experience.

2 answers 2

A preliminary assessment of the layout on different screens can be performed directly in the visual editor of Android Studio, but this is a very rough look and the final tests need to be done on real \ virtual devices.

Currently, the use of alternative emulators, such as Genymotion, makes sense only if you have an AMD processor on Windows OS, otherwise the emulator from the SDK is preferable anyway. as it allows you to create any device for tests (in the manual mode of device creation).

In the native emulator, you can make several devices with different screen sizes and pixel density (or select existing presses) and test the markup for them. For this task, the emulator is quite enough and on a real device with the same screen characteristics, problems will be only in very specific cases that can be simply ignored (which non-professional custom firmware on the device). Genymotion also has a certain set of test devices and it covers the main sizes, but sometimes they are not enough.

You can look at the official Dashboard for the most up-to-date test devices (and, in general, support by your application), where the percentages of using certain devices are indicated.
Minimum set:

  • phone hdpi, xhdpi on 4 ", ~ 5", ~ 6 ".
  • Tablet on 7 "and 10" (even if you do not count on it specifically, the application should look decent yet, the user can run it and not on the tablet).
  • OS - android 4.4, 5.1, 6.0

For additional questions in the comments.

The term layout is usually embedded meaning that it is the relative position of the widgets on the screen. So, the layout in android is practiced adaptive, that is, one for a variety of screen sizes. Individual resources with separation by size / screen density are mainly used only for graphic files on the screen, and this is due to the fact that a significant resource is wasted scaling and processing a single bitmap image, on weak devices it may well end in the application dropping. on OoME, but the resources of powerful devices should not be wasted. Also, when scaling, the image quality can be significantly affected (loss of details, ladders, soiling, etc.)

The theme of supporting various screen resolutions is very voluminous, but repeatedly discussed on this resource. To write everything once again I see little point, so let's go over the existing one.

The decision about how many screens (layout) is required to impose in the application is made based on the differences in the layout on the screen, and not its size.

Graphic files are selected based on the pixel density on the device, there is also an alternative (recommended) solution. On preparing graphic files in your application and adding them to the project.

The above answers also contain links to other answers, they are also worth reading.

PS: I pointed out references to my past answers, because I know what it says there and it is easier for me to find them. Of course, other participants also wrote many useful answers on this topic and you can use the search on the resource to learn more.

  • Thanks for the answer. Tell us about testing in Genymotion not of the appearance, but of the functional, whether it will show the real operation of the device, i.e. Will everything work in the same way on a specific physical device model with the same api version, resolution, density? - Vitya Minashkin
  • @Vitya Minashkin is not, the emulator does not fully emulate the real device, rather, it is the reference behavior for the characteristics indicated in the emulator. The manufacturer can significantly change the firmware and this can affect the behavior of the program, especially with these are Xiaomi, HTC and Samsung. Instead, thank you vote here - if the answer helped you, you can vote for it, you can also accept the answer that most fully solved your problem (gray arrows and a daw to the left of the answer) - pavlofff
  • Good. Here you have a tick instead of thanks. - Vitya Minashkin

Such a question, you need to impose under each density of screens mdpi hdpi xhdpi xxhdpi xxxhdpi?

Yes, it is necessary to impose separately. This is usually done like this:

  1. The picture is taken in good quality (at least 2k)
  2. Scaled to the desired size (a decent body like Corel or Photoshop)
  3. If we are talking about icons, then you can use Android Asset Studio

The application will only support portrait orientation and should work only on smartphones (up to about 7 inches), not on tablets. How to do it better? How to be with pictures?

Play with the flags in the manifest:

 <supports-screens android:anyDensity="true|false" android:largeScreens="true|false" android:normalScreens="true|false" android:smallScreens="true|false" android:xlargeScreens="true|false" /> 

Unfortunately, there is no way to test on different physical devices, is it possible to do all this in Genymotion

Yes, GenyMotion is the perfect tool for this.

There is a possibility that something in the application will not work in the emulator as if it were on a physical device?

Of course. So be it. Testing on the emulator will reveal 90-99% of problems (depending on the quality of the layout of the layouts)

Share your experience

  1. Do not use absolute units in the form of px in the layouts - ideally if everything is done in the form of dpi
  2. Do not resize software
  3. Order pictures from designers not in the form of JPG / PNG, but in Corel or Photoshop format - it’s easier then to scale them.
  • right in Android Studio is a built-in Image Asset Studio , which cuts icons and immediately scatters the right folders. - pavlofff
  • Thanks for the answer. Another question about the layout of layouts. Do you need to add layouts to the project depending on the screen size (diagonal in inches) and resolution density (dots per inch)? Those. for each size all the necessary density? There will be many layouts. - Vitya Minashkin