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?

DaveNOTDavid
  • 1,753
  • 5
  • 19
  • 37

1 Answers1

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?

robkriegerflow
  • 716
  • 5
  • 13
  • 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? – DaveNOTDavid Mar 17 '16 at 02:07
  • 1
    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. – robkriegerflow Mar 17 '16 at 03:57
  • But I thought the drawable directories are density-based (dpi) as opposed to dp... – DaveNOTDavid Mar 17 '16 at 15:00
  • Here's my other question that would justify what I mean: http://stackoverflow.com/questions/36065494/differences-between-scaling-images-with-dpi-as-opposed-to-dp – DaveNOTDavid Mar 17 '16 at 15:49