0

I read the document:

Supporting Multiple Screens

But still can't figure out how to support all screen resolutions in Table 2 in the document. Even if I create three versions for LDPI, MDPI and HDPI, there are more than screen resolutions in that table, if there is no matching image, it will scale my image and may not retain the aspect ratio.

Is there any standard way to deal with this? Thanks!

Heuristic
  • 5,087
  • 9
  • 54
  • 94

2 Answers2

1

See this question: How to scale an Image in ImageView to keep the aspect ratio answered by Steve H

  1. Yes, by default Android will scale your image down to fit the ImageView, maintaining the aspect ratio. However, make sure you're setting the image to the ImageView using android:src="..." rather than android:background="...". src= makes it scale the image maintaining aspect ratio, but background= makes it scale and distort the image to make it fit exactly to the size of the ImageView. (You can use a background and a source at the same time though, which can be useful for things like displaying a frame around the main image, using just one ImageView.)

  2. There isn't "white space", it's filled with transparent pixels. If you don't want even those, you could simply put your layout_width="fill_parent" and layout_height="wrap_content".

    Then as Samuh wrote, you can change the way it default scales images using the android:scaleType parameter. By the way, the easiest way to discover how this works would simply have been to experiment a bit yourself! Just remember to look at the layouts in the emulator itself (or an actual phone) as the preview in Eclipse is usually wrong.

Community
  • 1
  • 1
jkhouw1
  • 7,320
  • 3
  • 32
  • 24
  • Thanks for your reply, but what if I want to set background of a LinearLayout for the whole screen? Do I have to make the layout to be RelativeLayout and use ImageView instead of setting layout's background? Thanks! – Heuristic Jun 16 '11 at 02:23
  • I havent tried but maybe just nest your linearlayout content – jkhouw1 Jun 16 '11 at 02:55
0
<supports-screens android:normalScreens="true"
    android:largeScreens="true" android:anyDensity="true">
</supports-screens>

put the above code in your android manifest file using it your application is support all the screen size.

I hope this is help.

DynamicMind
  • 4,240
  • 1
  • 26
  • 43