0

On my Android app, I have a screen with an image.

The image is 600px wide. On my Galaxy SIII, this looks how I want it to look. But on phones with double the resolution it looks really small.

With shape objects that I define in xml, it's easy to define the width in dp units so it looks consistent on all phones.

But how do I do the same with an image that is physically only a certain amount of pixels?

CodyBugstein
  • 21,984
  • 61
  • 207
  • 363

3 Answers3

0

Use different different Resolution images for each screen size

akshay bhange
  • 2,320
  • 2
  • 28
  • 46
0

You can get the screen resolution and then adjust your image

 Gdx.graphics.getWidth();
 Gdx.graphics.getHeight();

I hope it helps :)

Taimur Ayaz
  • 312
  • 1
  • 6
  • 18
  • How do you adjust the size of the image programatically? – CodyBugstein Oct 02 '14 at 13:29
  • there are many ways to do that one of the ways is that your can create a linearlayout in your xml file and assign it an id. Then initialize that layout in your activity and create a new imageview after determining the resolution set the width and height of the image and add it to the layout. Please mark this answer as correct if I helped you thanks :) – Taimur Ayaz Oct 02 '14 at 13:40
0

You should use different images for different screens See http://developer.android.com/guide/topics/resources/providing-resources.html or change scaletype on imageview.

QArea
  • 4,955
  • 1
  • 12
  • 22