Layout Based on Orientation

by Scoz » Sun, 07 Sep 2008 04:30:35 GMT

Sponsored Links
 Currently trying to have a dialog that will allow the user to sign in
to a service using a Webview. Using a simple LinearLayout works while
while the phone is held in portrait mode, with the message and button
on top leaving a nice squareish webview. When switching in to
landscape mode though I end up with an unusably low height webview as
the message and button are still on top.

Is there any way to specify a layout based on the current orientation?


Layout Based on Orientation

by Mark Murphy » Sun, 07 Sep 2008 04:33:32 GMT


Sure. Put one layout in res/layout and another in res/layout-land. Here, 
layout-land effectively means "use this layout when the device is in 
landscape orientation".

When the device is rotated, your current activity will be closed 
(shortly after onSaveInstanceState() is called) and then restarted with 
the appropriate layout set. Reload your widgets from the instance state 
supplied to onCreate()/onRestoreInstanceState(), and you're set.

Mark Murphy (a Commons Guy) 
_The Busy Coder's Guide to Android Development_ Version 1.1 Published!


Sponsored Links

Layout Based on Orientation

by Scoz » Sun, 07 Sep 2008 07:59:15 GMT

 Awesome, this is exactly what I needed, thanks :D


Other Threads

1. Custom Android SubMenu

I would like to you how can I customize the defaut android subMenu
My objective is if for each item of the submenu to have (Text, 2
imageViews ).
Do I need to write and ListAdapter??




2. delivers wrong info


I have the following setup. I have a 1.6 phone with an apn that
requires a proxy, in addition I have a wifi connection that does not
require a proxy (or maybe it requires a different one).
My app uses in order to find out
the current proxy settings but even if I am on wifi, this call returns
the proxy from the currenctly selected apn.

So is this a bug or intentional? In any case how do I get the correct
proxy (or the lack thereof) information?



3. WebView.loadUrl on a hidden view opens the android browser

4. Autohide Scrollbar in ListView

5. Any API to send FAX from Android Application?

6. Today Widget

7. Does android support raw IP GPRS interface like NDIS in Windows Mobile