Is modifying the dp size as opposed to pixels recommended for various screen sizes?
Asked Answered
G

1

0

Say, for an ImageButton on screen A (240X320: ldpi) and screen B (720X1280: xhdpi), is it recommended to manually change the dp (layout-width and height) size of it in each unique layout resource file for various screens? Or, create scaled nine-patch bitmaps for each dpi size of the image, call it on the drawable resource file, and then set it as the src for the ImageButton?

To justify, here's what I mean: https://www.youtube.com/watch?v=OtsZbdbC370 ... Most likely, the video is outdated, correct?

Grunter answered 16/3, 2016 at 20:42 Comment(0)
E
1

It is entirely up to you if you want to change the layout width and height (in dp) of an imageButton. There is certainly nothing wrong with setting width and height of an imageButton or any UI element for that matter, in each unique layout resource file for various screens. Did you have specific code you wanted to get feedback about?

Erda answered 17/3, 2016 at 1:55 Comment(4)
Thank you for the response. So with that in mind, is there any point in creating all of the scaled dpi drawable resource directories (drawable-hdpi, drawable-mdpi, and etc.) consisting of the png files?Grunter
I would definitely create the drawable directories and put the proper dp sized images in them, bec the device will automatically choose from these dirs (matching its own dp profile with the image in the corresponding directory). As you alluded to: you could create different res/dimens directories for various devices based on "minimums" e.g. w800dp/dimens.xml and then create elements in that specific dimens.xml e.g. values-w411/dimens.xml for width and height that correspond with your images that aren't fitting well when you test your app.Erda
But I thought the drawable directories are density-based (dpi) as opposed to dp...Grunter
Here's my other question that would justify what I mean: #36065994Grunter

© 2022 - 2024 — McMap. All rights reserved.