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. Rules Engine for Android

Currently there is a desire to port over an application that uses the
Drools libraries.  The rules engine system as expected would not
simply convert from its jar files over to the dex files.  It seems as
if that would be a very unlikely situation.
However, is there an existing rules engine that the Android already
supports?  If so, the secondary option would be to take the existing
set of rules and change the syntax around so that we could use the
Android compliant rules engine and the existing code.

"Debugging is twice as hard as coding something the first time.
Therefore, if you write the code as cleverly as possible, you are, by
definition not smart enough to debug it."

2. N1 & bathaghor

Sampe today blum ada yg mau nraktir nih, blum kelihatan penampakan the 
superphone NexusOne  bersebelahan dengan batagor :-) 
Atau batagornya yg langka?


Lucky Sebastian
@google android

3. getDrawable() Resourses$NotFoundException

4. 16 Things I Like about the Google Nexus One (and 8 I don't) "jkontherun"

5. Talk Show Android

6. BT a2dp resume fail, a2dp_write failed err: -110

7. Getting a view in a non-Activity class