-3

I know it is possible to set values for image's height and width with density float values depending on the screen specs.

DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);
        mScale = metrics.density;

 animationLayout.width = (int) (60*mScale);
        animationLayout.height = (int) (60*mScale);

the imageviews I use look distorted a bit. Can you give me general idea/algorithm on how to make images look proportionally on different screen dimensions, densities? like this: get device's screen density. calculate all width/height - setWidth(50*mScale), setHeight(50*mScale)?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
ERJAN
  • 23,696
  • 23
  • 72
  • 146

1 Answers1

1

If you want it to occupy the whole screen, just set its android:height and android:width attributes to match_parent in the xml, it will autoscale to fill the whole screen.

Now, if you want it to show a picture and not distort it, you put the picture in the src attribute. If you want it to get distorted so it fills the whole screen, put it in background.

If you want different pictures to be used for different densities, put those pictures in the different drawable folders (-ldpi, -mdpi, -hdpi, -xhdpi...), android will use the right one for the current devices density.

Squirrelkiller
  • 2,575
  • 1
  • 22
  • 41