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. [newbie] App crashes on phone but not on the emulator

Hi all, i decided to start learning how to develop 3D apps for
Android. I started reding a lot of documentation (the red book mainly)
and experimenting a lot, copying code from the ApiDemos project.

The thing is, tests were going fine within the emulator, then i tried
to load the app in my phone (Motorola Milestone, Android 2.1) and when
it started, it crashed.

I cannot find what is causing this, i hope someone can help me.

Here's what i can get from logcat, let me know if you need anything
else.


I/ActivityManager( 1285): Starting activity: Intent
{ act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=test3D.test3D/.test3D }
I/ActivityManager( 1285): Start proc test3D.test3D for activity
test3D.test3D/.test3D: pid=13341 uid=10102 gids={1015}
D/ddm-heap(13341): Got feature list request
D/ViewFlipper(10690): updateRunning() mVisible=false, mStarted=true,
mUserPresent=true, mRunning=false
D/libEGL  (13341): loaded /system/lib/egl/libGLES_android.so
D/libEGL  (13341): loaded /system/lib/egl/libEGL_POWERVR_SGX530_121.so
D/libEGL  (13341): loaded /system/lib/egl/
libGLESv1_CM_POWERVR_SGX530_121.so
D/libEGL  (13341): loaded /system/lib/egl/
libGLESv2_POWERVR_SGX530_121.so
I/ActivityManager( 1285): Process com.android.settings (pid 13329) has
died.
I/DEBUG   ( 1047): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG   ( 1047): Build fingerprint: 'MOTO_TELUS/umts_sholes/
umts_sholes/sholes:2.1-update1/SHOLS_U2_03.11.0/900329:user/rel-keys'
I/DEBUG   ( 1047): pid: 13341, tid: 13347  >>> test3D.test3D <<<
I/DEBUG   ( 1047): signal 11 (SIGSEGV), fault addr 00000000
I/DEBUG   ( 1047):  r0 47017084  r1 00000000  r2 00000064  r3 0000000c
I/DEBUG   ( 1047):  r4 00312ca0  r5 00313b00  r6 00000001  r7 00000007
I/DEBUG   ( 1047):  r8 00000031  r9 00000000  10 00000003  fp 00000001
I/DEBUG   ( 1047):  ip 80000000  sp 467cfcf8  lr 81006a44  pc
afe0df48  cpsr a0000050
I/DEBUG   ( 1047):          #00  pc 0000df48  /system/lib/libc.so
I/DEBUG   ( 1047):          #01  lr 81006a44  /system/lib/egl/
libGLESv1_CM_POWERVR_SGX530_121.so
I/DEBUG   ( 1047):
I/DEBUG   ( 1047): code around pc:
I/DEBUG   ( 1047): afe0df38 24c0c001 24c0e001 e1b0ce83 aa000001
I/DEBUG   ( 1047): afe0df48 f4a1030d f480031d 3a000001 f421070d
I/DEBUG   ( 1047): afe0df58 f400071d f5d1f000 f5d1f040 e2522040
I/DEBUG   ( 1047):
I/DEBUG   ( 1047): code around lr:
I/DEBUG   ( 1047): 81006a34 e59c102c e59c2024 e1a0e00f e59cf034
I/DEBUG   ( 1047): 81006a44 e2866001 e2855004 e5942eb0 e3a03001
I/DEBUG   ( 1047): 81006a54 e1560002 3affffec e2840d77 e1a01008
I/DEBUG   ( 1047):
I/DEBUG   ( 1047): stack:
I/DEBUG   ( 1047):     467cfcb8  00000000
I/DEBUG   ( 1047):     467cfcbc  00000001
I/DEBUG   ( 1047):     467cfcc0  00000003
I/DEBUG   ( 1047):     467cfcc4  00000001
I/DEBUG   ( 1047):     467cfcc8  00000800
I/DEBUG   ( 1047):     467cfccc  00000004
I/DEBUG   ( 1047):     467cfcd0  00000000
I/DEBUG   ( 1047):     467cfcd4  00000000
I/DEBUG   ( 1047):     467cfcd8  00000000
I/DEBUG   ( 1047):     467cfcdc  00312ca0  [heap]
I/DEBUG   ( 1047):     467cfce0  00313afc  [heap]
I/DEBUG   ( 1047):     467cfce4  00000000
I/DEBUG   ( 1047):     467cfce8  00000007
I/DEBUG   ( 1047):     467cfcec  00000031
I/DEBUG   ( 1047):     467cfcf0  df002777
I/DEBUG   ( 1047):     467cfcf4  e3a070ad
I/DEBUG   ( 1047): #00 467cfcf8  47017084  /dev/pvrsrvkm
I/DEBUG   ( 1047):     467cfcfc  81006a44  /system/lib/egl/
libGLESv1_CM_POWERVR_SGX530_121.so
I/DEBUG   ( 1047):     467cfd00  00312ca0  [heap]
I/DEBUG   ( 1047):     467cfd04  00000007
I/DEBUG   ( 1047):     467cfd08  00000000
I/DEBUG   ( 1047):     467cfd0c  0000000c
I/DEBUG   ( 1047):     467cfd10  8106a5e4  /system/lib/egl/
libGLESv1_CM_POWERVR_SGX530_121.so
I/DEBUG   ( 1047):     467cfd14  810080d8  /system/lib/egl/
libGLESv1_CM_POWERVR_SGX530_121.so
I/DEBUG   ( 1047):     467cfd18  0011ca28  [heap]
I/DEBUG   ( 1047):     467cfd1c  0031de38  [heap]
I/DEBUG   ( 1047):     467cfd20  00000000
I/DEBUG   ( 1047):     467cfd24  00000007
I/DEBUG   ( 1047):     467cfd28  47102450  /dev/pvrsrvkm
I/DEBUG   ( 1047):     467cfd2c  00312ca0  [heap]
I/DEBUG   ( 1047):     467cfd30  8106a5e4  /system/lib/egl/
libGLESv1_CM_POWERVR_SGX530_121.so
I/DEBUG   ( 1047):     467cfd34  00000007
I/DEBUG   ( 1047):     467cfd38  00000000
I/DEBUG   ( 1047):     467cfd3c  00000003
I/ActivityManager( 1285): Process com.motorola.worldclock (pid 13324)
has died.
I/WindowManager( 1285): WIN DEATH: Window{450c90f8 SurfaceView
paused=false}
I/WindowManager( 1285): WIN DEATH: Window{44e73008 test3D.test3D/
test3D.test3D.test3D paused=false}
I/ActivityManager( 1285): Process test3D.test3D (pid 13341) has died.
I/UsageStats( 1285): Unexpected resume of org.adw.launcher while
already resumed in test3D.test3D
I/DEBUG   ( 1047): de{*filter*}d committing suicide to free the zombie!
D/Zygote  ( 1059): Process 13341 terminated by signal (11)
I/DEBUG   (13348): de{*filter*}d: Jun  8 2010 19:34:11
D/ViewFlipper(10690): updateRunning() mVisible=true, mStarted=true,
mUserPresent=true, mRunning=true
W/InputManagerService( 1285): Got RemoteException sending
setActive(false) notification to pid 13341 uid 10102
W/InputConnectionWrapper.ICC( 1345): Timed out waiting on
IInputContextCallback


Thank you very much in advance,

kind regards,
Franco

-- 

2. Global Search replacement app

I would like my app to replace the Google Quick Search Box. Basically,
I want my app to be the default app for when the user presses (not
long press) the hardware search button. Is this possible? If you are
wondering why: my app is an alternative to QSB which I think works
much faster and is much more practical.

-- 

3. Calling all Android App Developers

4. Open another application with only the package name

5. startActivity() in monkeyrunnner doesn't work

6. bluetooth support on Emulator in Honeycomb???

7. How to get the permission to surface->creatoverlay()?