views:

481

answers:

4

how to differentiate the 480X800 and 480X854 screens. we have an option to put the one image at the hdpi folder.in my case 480X800 image is does not support for the 480X854 image. it shows a blank space at the bottom.Any Idea?

Edit: i set the image as a background. on my layout i have transparent image views with margins. if i click the image view it do some task. but between these two screens. i can adjust the value for one. in another one the image was strectched slightly. then what can i do? can you understand my problem? please help.

+1  A: 

You can pull the resolution from the current running process, but you can't pull the exact resolution. As I know, their is no way to differentiate between the two "large" displays, the best you can hope for is supporting any size with your app.

If your displaying an image (and assuming you made the Application available to all screen sizes) just make the image as big as the larger resolution and not let the other bit display. If the image file is small you should not have a problem.

BTW, I solved the problem first by making the Application layout accessible to all screen resolution, and customizing for the lower resolutions.

hope it helped!

Justin
+3  A: 

You shouldn't really have to differentiate between the two; you should make a best effort to just support each screen density rather than specific screen resolutions. Otherwise, you'll end up in a mess when devices with yet-different screen resolutions come out. This is why we have nine-patch images! :)

See also this question:
http://stackoverflow.com/questions/2561598/what-resolution-should-my-android-splash-screens-be

If you absolutely need to differentiate between the two, you can use the long and notlong resource qualifiers. e.g. WVGA is values-hdpi-notlong and FWVGA is values-hdpi-long.
Apparently this isn't correct, which is all the more reason to not differentiate and create generic resources that can handle small changes in resolution.

Christopher
WVGA and FWVGA both are come under values-normal-long. Check this: http://developer.android.com/guide/topics/resources/providing-resources.html#table2 Is there any other possible to differentiate WVGA and FWVGA?
Praveen Chandrasekaran
Oh, indeed; I wonder if that has changed or I imagined it. In that case, there may well be no (non-deprecated) way of doing it.
Christopher
+1  A: 

Christopher's right, you should make your app flexible but if you do need the actual screen resolution you can use:

Display d = ((WindowManager)activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();

From there you can rescale or zoom in/out as needed or just use 9patch. It depends on the application of course but you may consider putting 480x854 image in your res/ folder and make sure it looks right on 480x800 just centered.

Gilead
i set the image as a background. on my layout i have transparent image views with margins. if i click the image view it do some task. but between these two screens. i can adjust the value for one. in another one the image was strectched slightly. then what can i do? can you understand my problem? please help.
Praveen Chandrasekaran
A: 

Hi everyone! I am also facing the same problem. Is there any other way to handle 480X800 and 480X854 screens using xml layout.

Thanks!

audum