5

I'm facing the next problem:

I have a values-xxhdpi with their dimensions.xml. Devices with 480 dpi work great with this folder.

The problem is that for example Samsung Galaxy S4 or S5 catch the values from this folder and not look well in screen because they have a 420 dpi. So I need to create a values-SOMETHING to this type or devices.

I try adding values-w410dp and work fine, but if I add this folder the devices with 480 dpi now catch de values from this folder and not the values from the values-xxhdpi.

Please need sugestions

Thanks

user3240604
  • 407
  • 1
  • 8
  • 22
  • 1
    `values-w410dp` has nothing to do with screen density. I would focus instead on designing a more flexible UI, where the small difference between 420dpi and 480dpi is not an issue. – CommonsWare Feb 15 '17 at 15:45
  • @CommonsWare Its only a button with wrap-content in width and height and margin right and top. nothing else. How more flexible can i do that. Margins with dps. The problem is that in screens with 420 dpi the width is smaller i think, because the width of the image is smaller. And both screens have 1080*1920 – user3240604 Feb 15 '17 at 16:19
  • "Its only a button with wrap-content in width and height" -- from a programming standpoint, you are saying that you do not care about the actual size of the button. If you want the button to be a consistent size, **set it to be the consistent size**, rather than assuming that it will become a consistent size, magically, based on other things. – CommonsWare Feb 15 '17 at 16:24
  • I need that the button matches de background. The background has a draw that defines the background button. I'm saying "Its only a button with wrap-content in width and height" to describe that is a simple code! – user3240604 Feb 15 '17 at 17:45
  • 1
    "I need that the button matches de background" -- and there is your mistake. That approach will not be reliable, as you have no means of ensuring that those things will line up. – CommonsWare Feb 15 '17 at 17:55
  • 1
    @CommonsWare I understand. What i don't understand is why a device with 1080*1920 5,0'' (Nexus 5) is xxhdpi and 1080*1920 5,1'' (Samsung Galaxy S5) is 420dpi. All images in the Samsung S5 are smaller! – user3240604 Feb 16 '17 at 19:28
  • 1
    does anyone have solution for this? This also happens with xhdpi res too; as there are two variants for xhdpi 720*1280 and 768*1280. this minor difference of 48px can disturb views aligned with background. – Dhaval Patel Aug 18 '17 at 06:52
  • Any one figured out the solution? – karthik kolanji Oct 15 '18 at 10:41
  • 1
    Any update on this? 2019 anyone? – shanraisshan Jul 31 '19 at 12:35

1 Answers1

5

You have to create dimension resource files for different screen sizes with different dpi.

As you can see here:

android:screenSize=   ["small"| "normal" | "large" |     "xlarge"     ]

android:screenDensity=["ldpi" |   "mdpi" | "hdpi"  | "xhdpi"| "xxhdpi"]

            dpi   [ "280" | "360"| "420"| "480" | "560" ] 

Add your screen dimension with density and define your attributes.

Bartosz Zasada
  • 3,762
  • 2
  • 19
  • 25
user3500198
  • 57
  • 1
  • 5
  • Please can you explain a bit more, you are talking about creating a folder like layout-xxhdpi-420dpi – shanraisshan Jul 31 '19 at 11:34
  • Is that not a lot of layouts that will be needed to be created for aligning a simple view with the background? – John Dec 11 '19 at 06:56