I have a TextView in a ConstraintLayout with layout_marginTop=@margindimen and layout_marginBottom=@margindimen attributes. As there are different screen sizes, the margin value should change according to the specific screen. This is why I have created in dimens folder dimens/dimens.xml(small), dimens/dimens.xml(normal), dimens/dimens.xml(large)... and set the value of "margindimen" in each screen size dimens file. I have seen that a 480x854px device and a 720x1080px device are both from dimens(normal) so there is a huge difference of size between those devices. This is why I was wondering if it was better to make different values according to the screen density and not according to de screen size: dimens/dimens.xml(ldpi), dimens/dimens.xml(hdpi), dimens/dimens.xml(xhdpi)...
If making different values according to the screen density will make me have the same problem, how could I solve it?
I think you should create different
dimensfiles withsmallest-widthselection. This allows you to identify small/normal/big screen.Take a look at this guideline. There talking more about column optimization, but you also may change spaces this way.
Your files will looks like this:
Also take care about portrait/landscape orientation, because in rotation case smallest-width will be changed.