0

I have the following dimens file:

enter image description here

I have tested the app in a 240x400px (ldpi) device. So the height's dp is = 400/(120(ldpi)/160)== 533.33dp

So if I am not wrong, dimens.xml(h533dp) will be used by devices whose height's dp is equal or grater to 533dp. So, why if I am testing the app in a device with 533.33dp of height, it is not using the dimens that are defined in dimens.xml(h533dp)? I'm going off my head...

sacacorchos
  • 163
  • 9
  • 533 < 533.33 Turn it into h530dp and see if that fixes it. The real question is WHY are you doing this to begin with- anytime you make a layout file this specific, it means you have a major programming mistake in your UI and you're trying to bandaid it. That's always a mistake- you'll need to make so many of these and spend so much time, effort, and bugs maintaining them that it's never correct to do this rather than fix the real problem. – Gabe Sechan Dec 18 '22 at 20:37
  • @GabeSechan The purpose of having different values according to the screen size is because I have a ConstraintLayout with some items that have Top and Bottom margin and in some devices that margin is not looking good. In this post I made, someone suggested me to use different margin values according to the screen size: https://stackoverflow.com/questions/74675738/how-to-solve-textview-being-cropped-in-small-devices-because-of-layout-margin . – sacacorchos Dec 18 '22 at 23:07
  • After that post, I made another that didn't have any answer. I made it to ask how many different dimens.xml files I had to create to support all the devices as there are a big amount of different devices: https://stackoverflow.com/questions/74756490/how-many-dimens-files-are-needed-to-support-all-the-devices-according-to-the-scr . For what you are telling me, I think it is not a good solution to create different dimens files to fix the problem. I would appreciate a lot if you could lend me a helping hand :) – sacacorchos Dec 18 '22 at 23:13
  • You can use different margins for different screen size, but it wouldn't be a *specific* screen size. It would be wide categories of screen size. Most apps have 2-3 of these at most, across everything from the smallest device to the biggest tablet. – Gabe Sechan Dec 19 '22 at 05:54
  • @GabeSechan --It would be wide categories of screen size-- that's the point, I would like to know how could I know all the dimens.xml(hYYYdp) files I have to create so that all the screen sizes are managed. --Most apps have 2-3 of these at most-- what I have done is to make a dimens file that is working for a speific device (240x400px (ldpi)) and my plan is to make more and more of different devices like this one. But, now I am confused because you have told me that dimens files should't be created for specific screen size devices and most apps only have 2-3 spcecific devices dimens files – sacacorchos Dec 19 '22 at 19:27
  • If I don't have to create specific dimens files to manage/support all the screen size devices, what should I do? Please I would like you to help me as I have seen that I am not doing it correctly and there is a better way to do it. Please, you can answer me here or in the question of dimens files I made. You don't know how much I would appreciate it because I am already a bit desperate with this topic because I can't find so much information on what dimens.xml files I should create exactly and how many of them. Thanks :) – sacacorchos Dec 19 '22 at 19:32
  • @GabeSechan sorry for too much questions, but why 530 is working and 533 isn't if 533 < 533.33 but also 530 <533.3 ? What is the difference between 533 and 530? – sacacorchos Dec 20 '22 at 19:10

0 Answers0