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. webkit modification question

I'm asking an OEM to add some reporting hooks to the Webkit code.
They have lawyers in Japan that think that the android webkit version
is only LGPL and they'd have to release source and ways to link
everything again.  I think the Webkit code in android has both the BSD
license and the LGPL in the notice file and they need only comply with

Is there a nice big "it's legal to do release a webkit library with
modifications in the android code base under the BSD license"
explanation that would be easy for a non-native English speaker could


2. How to play youtube videos within webview using HTML5


I have a listview that populated at runtime based on server response.
I want to play youtube video in webview on click of list items.

Can anybody let me know in detail how can I use <video> tag of HTML5
in android.

Thanks & Regards,
Sanjay Ujjainkar

---------- Forwarded message ----------
From: Sohil
Date: Tue, 4 Jan 2011 04:48:17 -0800 (PST)
Subject: Re: How to play youtube videos within custom android activity


Try using <video> element of HTML5, though its experimental. but it
help for your problem
put the webview component and load the static file with dynamic url
It wont work for all the video that would be the limitation.
Its supported in android 2.0+ .

<video id="video" autobuffer height="240" width="360">
<source src="BigBuck.m4v">
<source src="BigBuck.webm" type="video/webm">
<source src="BigBuck.theora.ogv" type="video/ogg">


3. How to clear activity stack

4. Converting screen coordinates to world coordinates?

5. InstrumentationTestRunner with Annotation

6. Getting Generic Failure when sending Many SMS (Android)

7. How to find out in which mode Landscape or portrait?