Question

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.

Was it helpful?

Solution

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!

OTHER TIPS

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:
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'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.

create folder layout-hdpi-854x480

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top