by Bobbie » Tue, 10 Feb 2009 10:49:17 GMT

Sponsored Links
 I have a couple different questions:

1) Does Google think there will only be one screen size on Android
phones?  The reason I ask is because I haven't been able to find
anything on "variable" layouts in Android?  I would like to create a
layout with 2 webviews, one 80% of screen height and the other 20%.
Is this even possible, or do I need to assign the height of each as a
static "px" value?

2) How do I preserve the data in my views when someone switches
between landscape and portrait?  I doubt it's hard, but I've not been
able to find it.  Can someone post an example?

Thanks everyone!


by Romain Guy » Tue, 10 Feb 2009 12:05:13 GMT

 > 1) Does Google think there will only be one screen size on Android


All layouts are variable.

That's what wrap_content, fill_parent, weight and in some measure the
dip unit are for.

It's done automatically for all the views with an id.

Romain Guy
Android framework engineer

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them


Sponsored Links


by Marco Schmitz » Tue, 10 Feb 2009 21:11:38 GMT

 try to create a folder "layout-land" and "layout-port" next to "layout".

just place main.xml inside both folders but not inside "layout".

swapping the layout (numlock+7 inside the emulator) will show you the
best fitting xml file.


2009/2/10 Romain Guy <>:



by Bobbie » Tue, 10 Feb 2009 22:25:28 GMT

 I tried using fill_parent, but somewhere I still have to specify a
"percentage" screen height instead of a "px" value, that's what I'm
having issues with.  Can you post an example of how to do an 80%
screen height with a 20% screen height below it?



by Ludwig » Tue, 10 Feb 2009 22:52:56 GMT

 2009/2/10 Bobbie <>

Android caters for different screen sizes already. The Openmoko Freerunner
runs Android quite happily on a larger resolution than the G1. If you edit
the skins for your emulator (they are just text files) it is quite easy to
simulate larger (or smaller) screen sizes for development.

Pretty much all layouts are 'variable', apart from the fixed ones: a
ListView will have more lines on a larger screen etc.

What you are after is the android:layout_weight="x" attribute for your view
elements. In your case you want, probably inside a LinearLayout, two
elements, one with a weight of 4, the other 1. The weights are relative, so
the first will get 80% of screen height, the other 20.





by Bobbie » Wed, 11 Feb 2009 19:09:37 GMT

 Ok, so I'm having trouble with this.  What I'm trying to do is design
a web-based chat interface using 2 webviews (one for the message
display and one to send messages).  I have the code for everything
ready and it works, I just need to figure out the whole layout thing.
Here is the code I have:

<?xml version="1.0" encoding="utf-8"?>
xmlns:android="" ;

The program runs in landscape mode.  The problems I am running into

1) The "chatview" webview is showing up at the bottom instead of the

2) When I hit the "back" button the app crashes.  I'm guessing this is
because the interface isn't designed right, but I could be wrong.



Other Threads

1. Android & Security: Can They Get Along

Join us for this webinar on Android Application Security:


2. Stop activity animation problem?

Hi All,
   I want dont want the activity animation that comes by default when
we start a new activity (i.e. the right to left scrolling effect to
new activity view) so i googled a bit and found a flag
FLAG_ACTIVITY_NO_ANIMATION in the Intent class also i applied that
flag to my intent via the setflags() method but somehow i still see
the activity animation when a new actvity is launced ( i am developing
in android 2.1 update).

     Please help me in this regards?


3. DDMS Telephony Status controls not working for the emulator in latest SDK tools

4. Quick search box QSB query in FROYO

5. about change the image view alternatively

6. Mod: Pre-order HTC Desire + Wildfire untuk member id-android

7. dateformatter