M
M
mixa0002021-04-09 12:55:38
Android
mixa000, 2021-04-09 12:55:38

How should I adapt text sizes, images sizes, buttons sizes etc. for different displays of android?

How do I adapt the size of text, button images, etc. to different screens? For example, to make text or images look readable on both the big and small screens. It is written on the Internet that you need to create folders with the prefixes hdpi, mdpi, and so on, but this is nonsense, this is not an adaptation, but a simple creation of several xml markups and thus it takes up extra memory space. I would like to use something like percentage or are there other solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-04-09
@zagayevskiy

To adapt the size of the text, there are sp units, for linear sizes - dp.
hdpi and so on are commonly used for various sizes of (usually bitmap) images.
For layouts - more often they distinguish between portrait (by default) and landscape (land) orientations, there are different xml files. Also often for devices with a large screen, the swXXXdp(smaller width XXX dp) postfix is ​​used, for example, sw600dp means that resources from this folder will be used only if the length of the smaller side of the device is greater than or equal to 600dp.
As for the rest, the layout should be designed for the fact that it will be pulled or squeezed. It is necessary to think whether this or that element will be placed in this case, and what if not.
More. Well, there in the left panel there are a bunch of links where you should also go read.
About the fact that xml will take up space in memory - no, it won't. I mean, it doesn't matter at all, you will never see a lot of memory consumption from xml.
Something about percentages - no, it's not supported. Make up the way the system offers you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question