I
I
Ilya2016-10-25 00:34:04
Android
Ilya, 2016-10-25 00:34:04

Why does the window look different in an android application with a given dpi on different devices?

I ran into this problem and I can't figure out what it is. The base relative layout has a nested block of the same type. In a nested block, let's say there are 3 editText. The nested realtive is set to height wrap_content , and both marginTop and marginBotom are set to dpi. Why on a device with a low resolution, this block does not fit all three editTexts, but less, trimming everything by the amount of marginTop. As I understand it, screen resolutions in dpi should be the same for all devices, or am I wrong? Then what's the point of using dpi if you still have to fit everything to different screens?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rou1997, 2016-10-25
@Rou1997

dpis used specifically for scalable sizes, and for fixed sizes it is used px.

M
mitaichik, 2016-10-25
@mitaichik

No, the screen size in dpi is different for different devices, depending on the screen diagonal. But (as I understand it), if the pixel size of similar screens can vary significantly, then in dpi they are approximately the same, plus or minus.
There are several groups of sizes ( mdpi, hdpi, xhdpi) - you need to dance from them, and set your own sizes for each group.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question