Differences between scaling images using dpi rather than dp

I have all the directories available for drawing (for example, xxhdpi and xxxhdpi?), Consisting of raster images from nine patches, a resource with the ability to draw in a drop-down directory that extracts all scaled raster images, and I set the Button backgrounds with the extracted resource file. .. Now my problem is that I also created “scaled” layout layouts in terms of size (small, normal, etc.), in which I tried to manually change the dp of the buttons as follows:

Here is my xhdpi bitmap:

enter image description here

... But it looks like a Nexus 7 virtual emulator (7.0 ", 1200X1920: xhdpi) in the layout-large directory:

enter image description here

... and when I manually resize dp to 200 one of the buttons:

enter image description here

^^^ What do my directories look like? ... And why does the button look like this? ^^^

All that was said, I just don’t understand why we need density-based directories (mdpi, hdpi, xhdpi, etc.) , as well as layout resource directories, when we can just change the dp of the images in each unique layout relative to screen size (small, normal, etc.).

0
android xml dpi layout bitmap
source share
1 answer

@ dpark14 I basically already answered the question that you asked in your post from yesterday: Does dp resize unlike pixels recommended for different screen sizes?

  • Perhaps you should edit your last question to include the code and images above so that it can be consolidated.
  • As I said in my answer (and one of the other comments said):

It is up to you if you want to change the width and height of the layout (in dp) of the image. Of course, there is nothing wrong with adjusting the width and height of the imageButton element or any user interface element, in this case, in each unique layout resource file for different screens. Did you have a special code that you wanted to receive feedback on?

Now that you have included some images, I see some of what you have.

You really should take a look at this: Android Studio upload folders

And it will be helpful for you to read the Android documentation again: http://developer.android.com/guide/practices/screens_support.html

To summarize a few general ideas: You do not need a folder with a default feature, but you should have the following:

  • drawable-mdpi (medium) ~ 160dpi
  • drawable-hdpi (high) ~ 240dpi
  • drawable-xhdpi (extra-high) ~ 320dpi
  • drawable-xxhdpi (extra-extra-high) ~ 480dpi
  • drawable-xxxhdpi (extra-extra-extra-high) ~ 640dpi

As the Android documentation says in the link above:

Your application achieves "density independence" when it preserves the physical size (from the point of view of the user) of the user interface elements when displayed on screens with different densities.

enter image description here

Instead:

enter image description here

If for some reason (apparently you are having problems) you have reached density, but your image doesn’t fit well when you can start joining with changes to w / h and res / layout

Also from my previous answer:

As you mentioned: you can create different res / dens directories for different devices based on “minima”, for example. w800dp / dens.xml, and then create the elements in that particular specific.xml, for example. values-w411 / dens.xml for widths and heights that match your images that don't work well when testing your application.

As a first step, maybe you should try. Yes, it takes time, but first try a standalone test different from your application. Just add one image (you may have problems). See what happens when you download it to different Nexus devices in an emulator. Does the image achieve "density independence", i.e. Saves physical size on all devices? If this is the case, and there is a problem with its w / h in relation to the limitations of a specific device, as I said in my previous answer, and now here, create the directory named (in the values ​​-... directory) specifically for the problem device change layout_width / layout_height for this particular image or view.

Learn more about a specific w / h device: https://design.google.com/devices/

0
source share

All Articles