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=" http://schemas.android.com/apk/res/ 
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/my_background">
    <ImageView ...
        android:id="@+id/my_imageview"
        android:src="@drawable/my_image" />
</RelativeLayout>

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 :

<ImageView
    ...
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="40dip"
    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 - MDPI : OK
- 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 !!
Regards

-- 



Other Threads

1. Help: ADT and Eclipse integration problem (I think)

Hello all,

I've installed the android SDK, Eclipse and the ADT plugin (got all
the latest versions from the official websites: eclipse 3.4.2 from
which I installed the ADT plugin and SDK 1.1_r1 from google).

I've set the SDK in eclipse and also added it to the PATH environment
variable (I'm running Win XP SP2) and have entered the necessary Run
configurations settings in eclipse.

Yet trying to open each of the sample projects and create a Hello
Android project of my own consistently gets the following error from
eclipse: R cannot be resolved.

I still don't know much about the framework but have read that the
R.java is suppose to be generated automatically. Eclipse suggests
adding an import to android.R, but the tutorial I'm reading seems to
have no such import and even if I add the import the problem persist
as the 'main' class simply isn't there.

I've changed the relevant code so to omit the use of the R class from
this:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

to this:

TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);

While this did make the aforementioned error go away I still couldn't
run the project since eclipse doesn't seem to work well with the ADT
plugin (that's my guess at least) and the doesn't build the project.

When I Run it I get the following output on the console:

[2009-03-08 09:19:09 - Hello Android] ----------------------
[2009-03-08 09:19:09 - Hello Android] Android Launch!
[2009-03-08 09:19:09 - Hello Android] adb is running normally.
[2009-03-08 09:19:09 - Hello Android] Could not find Hello
Android.apk!

The emulatore doesn't start of course. It seems to me like there's a
problem with the ADT and Eclipse so that the projects aren't created
properly (that R.java file is suppose to be created automatically
according to what I've read).

any clues as to what's gone wrong here and how can I fix it?

--~--~---------~--~----~------------~-------~--~----~

2. Help using Eclipse to "attach" to a process on the emulator...

I have a process running on the emulator but can't figure out how to
get Eclipse to
attach to it so I can debug it.

DDMS isn't doing anything useful, it does the "ps" and shows my
process but it is
"not DDMS aware", has no description and no VM version.  Threads don't
update,
heap doesn't show anything, allocations is blank...

Debugging through Eclipse's "Remote Java Application", set to port
8700 does
nothing for a while and then fails with a failed to connect to remote
VM error.

any help would be appreciated,

  mike

--~--~---------~--~----~------------~-------~--~----~

3. Paid applications in the UK

4. Build libbluedroid.so ERROR

5. gps mock location doubt

6. How to get a reference to a TabWidget in my java code

7. Flash Embed?