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. Anyone else seeing strange things with the latest Nexus One update (the 2.2.1 patch)

So far, I have received the "first part" of the update 3 different
times.  Once last Monday, again last Fri, and yet again this morning
(I was hoping the one this morning was finally Gingerbread, as recent
rumors point to today being the release date).   Only once (last Fri)
did I get the second part of the update after completing the initial

I didn't keep track of the build information on my phone, but from
what I can tell, it isn't changing (I am still on FRG83).

I have generally updated my phone manually, after each release is
announce (as opposed to waiting to get the update pushed
automatically), so I don't have a lot of experience with pushed
updates.  I expect this craziness is unique to this particular update.

Anyone else seeing the same sort of thing on their N1s?


2. One More Question TabHost Layout Question

Something I just noticed. If I don't have a picture and I just have text if
I set the height of the tab to say 45dp it cuts off the text. I tried to add
gravity="top" but that didn't do anything. Is there a way to move the text
up so it won't get cut off or should I create an Image that contains the
text I want to show so it fits in the tab?

-----Original Message-----
[] On Behalf Of akkilis
Sent: Friday, December 03, 2010 12:53 PM
To: Android Developers
Subject: [android-developers] Re: TabHost Layout Question

You can set the height of the "Tabs" of your TabHost or simply can provide
the images to them also to change their background.

Setting Height:

(Setting the height
                                <!--    Layout of Tab 1                 -->


Setting Image:

View v = tabWidget.getChildAt(i);



3. TabHost Layout Question

4. kernel 2.6.31 on Android 2.1

5. Save ID & name in list view

6. BroadCastReceiver SMS receiver Force Close on AVD

7. Gigabyte Gsmart MS820 - Android