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. Have View and ListView Scroll as one

What I have now is a layout that includes a list view at the bottom.
All of the items in the layout above the list view remain fixed as you
scroll through the list view.  I would like the entire page to scroll
so for example when you reached the bottom of the list you would no
longer see the items above the list view.

 What is the easiest way to accomplish this?


2. UI framework changes in Android 1.6

Is this a spam ?


3. How do I get a view's height to fill the space in between two other views?

4. Problem with installing the Composite ADB interface

5. 1.6 (donut) in Canada? is rooting the only option?

6. ADC2 - Allow apk update please!

7. Insufficient log / Scala deployment fails