Problem when dealing with multiple screen sizes

by lou » Fri, 20 May 2011 18:04:16 GMT

Sponsored Links
 Hi !
I have some problems when dealing with different resolutions and sizes
of screen : my goal is to display an image in a square which is draw
in my background picture.
I have a main RelativeLayout which is filling the entire screen :

<RelativeLayout xmlns:android=" 
    <ImageView ...
        android:src="@drawable/my_image" />

In my background picture, there is a square ( for example at 10px from
the left and 40px from the top of the picture ). I want to display the
ImageView my_imageview IN this square.
In my manifest :

    <supports-screens android:normalScreens="true" />
    <supports-screens android:largeScreens="true" />
    <supports-screens android:smallScreens="true" />
    <supports-screens android:anyDensity="true" />

I tried to set my_imageview parameters like that :

    android:layout_marginLeft="10dip" />

But even with 3 types of drawable ( hdpi -> 1.5x, mdpi -> 1x, ldpi ->
0.75x), the imageview is not always displayed in the square.
For this  example :
- HVGA - HDPI : the imageview is underneath the square
- WVGA - HDPI : the imageview is a little over the square
- WVGA - HDPI : the imageview is a lot over the square
I also tried to set the layout_marginTop and the layout_marginLeft
three times ( values-small, values-normal, values-large ), but there
are still some bugs..

Is there anybody who can help me with that ?

Thanks, a lot !!


Other Threads

1. Game grid images

I'm in the beginning process of creating my first 2d game and it's a
puzzle game (sort of
like bejeweled) where I would have 7 different images randomly spread
out across in a 7x7 grid
totaling 49 images total.
Basically there would be a way to match pieces and make them
disappear, then the pieces above
would fill the new empty spaces, and then new random pieces would
appear to fill the gaps left
at the top of the screen.

I have been struggling with this I know how to load images etc. but I
cant seem to wrap my
head around getting the basic getting this basic structure set up
where it's actually usable.
I cannot find any tutorials etc that cover this sort of thing. If
someone could give me any
pointers, or point me in a direction that my fill in the gaps for
what I am looking for that would be greatly appreciated.



2. Uploading an app to the Market for testing

:) Sorry. You yourself also wouldn't be able to test it if it remains


3. New Game: Flying Fighter Beta

4. 绛斿: MapView in android emul ator white screen

5. NodeList change in API 8 without notice?

6. How to track real time movement using android emulator

7. Android app with a lot of videos