1

I tested my application for screen sizes for 6 inches - 6.5 inches(on a one plus 6t/7t) and above and it's scaling the UI elements properly for it. But when I tested the application for screen sizes of 5 - 5.5inches, it's going out of the constraints and off the screen.

These are the things that I have tried:

  • Having wrap_content and match_parent with most of the UI elements(Textviews, Buttons to name a few)
  • Using constraint_layout which is the default layout in Android Studio 3.0 with all the constraints set for every element
  • I also tried understanding this document but I could not clearly understand this

Lastly, I came across their solution of having a different screen layout for different screen size. For this, what would I have to do? Create a new Layout and copy my Design XML text in the newly created layout and adjust scaling accordingly or is there a better approach for doing so?

Also, any other suggestions or any other approach to solve this would also help.

Edit 1:

So I figured something out, The UI is not setting correctly for xxhdpi resolutions. To compare, two screen sizes of similar sizes (1080x1920) having 420dpi and xxhdpi resolutions, the former works correctly but the latter does not. Any clues on how can I create or deal with xxhdpi resolutions?

Rishab Parmar
  • 369
  • 3
  • 16

1 Answers1

0

[try with this,you can update AS]

[1]: https://i.stack.imgur.com/oLqHI.png

  • I personally don't trust the emulator when it comes to UI. Reason being, I tried it over a 5 inch screen from the emulator and things were scaling perfectly well. I tried the same thing on an actual device with similar dimensions and the UI was blown out of place. – Rishab Parmar Jun 30 '20 at 08:16
  • this is true. You can cut back on this though by using support library versions because they should be the same. – John Lord Jul 01 '20 at 18:43