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. how to extract class information from code

Hi seniors,
  I have a huge codebase. I am not very clear about its design as
documents are rear to find.

Is there any tool available to construct the class diagram from the
code? I need to know the interactions between
the classes and relations between them.
If there is any such tool where i can give the entire code as input
and get the class diagram as out put, it will be best for my



2. orientation problem

i am facing a problem with orientation,when ever i change the
orientation some of the views in the layout are missing.
i used a vertical linear layout int which i placed some text fields
and buttons.but when i am changing to landscape it doesnt display all
the view.
for this onConfigauration chage i used so set contnet view of another
xml,which is suited for landscape and had to there any
alternative way for self adjustment of the views automatically???

awaiting replies urgently.


3. Android serial port

4. getSharedPreferences and static reference to a Context object

5. Dialog change orientation

6. emulator/ host network setup problems

7. horizontalScrollView + TabHost