0

I'm having a problem with image size showing on devices with different screen resolutions. So far, I noticed that the size is appropriate for 'smaller' devices - 240x320 , 320x400 , 400x800 (mostly, but not all of them)... but the problem occurs when I try it on, for instance, Galaxy S3 (which is 720x1300), even for some 400x800.

The problem is that the image which I wrap (and put dynamically on interface) won't show in original size. I went a step further - image is taken from server in exactly the size needed for particular device - I read the screen size and send it to server and the server returns the image with the needed size. After that I show it with the following code (must do it programmaticaly):

RelativeLayout rl = new RelativeLayout(context);
LinearLayout.LayoutParams rlLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
rlLayoutParams.gravity = Gravity.CENTER;
rl.setLayoutParams(rlLayoutParams);

ImageView imageMain = new ImageView(context);
RelativeLayout.LayoutParams imageLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
imageLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
imageMain.setLayoutParams(imageLayoutParams);

rl.addView(imageMain);

As you can see, I also have to use Relative layout because other images (icons actualy) are put over the main one (like badges in corners) so the LinearLayout is of no use... Any chance that this might cause the problem? Or, is there any other parameter(s) that must be taken in consideration, besides the screen resolution (screen width and height)?

Any experience on this issue would be of great help so please advise if any ideas...

4

1 回答 1

0

Place your images in the drawable-nodpi folder....

于 2013-02-17T12:21:12.703 回答