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)
 http://commonsware.com 
_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. small doubt regarding hello android

hi all,
    i am new to android i have installed the eclipse ganymede and into 
that  i have added ADT(android development tools) and android editors 
into updates
    later  i followed all the instructions given in the following site  
http://code.google.com/android/intro/hello-android.html#create  after 
changing the HelloAndroid code also still  i could see errors hence i 
have added Android library by moving into build path option of the 
project, then there were no errors  and hence i have given run and then 
it has given me different options like android ,java,etc etc i choose 
android  later  i got the following messages in console:
                         [2008-12-16 17:12:34 - HelloAndroid] Android 
Launch!
                         [2008-12-16 17:12:34 - HelloAndroid] adb is 
running normally.
                         [2008-12-16 17:12:34 - HelloAndroid] Could not 
find HelloAndroid.apk!                [ERROR]

can some one please help me out to resolve this issue, any help would  
be appreciated,thanks for the help in advance

                Thanks & Regards
                   kusuma.p



         


The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments contained in it.

--~--~---------~--~----~------------~-------~--~----~

2. Adb server problem

Hi i am new to android.Sometimes while running the emulator i get this
error.I don't know what to do.I restart eclipse 3/4 times.Sometimes it
works sometimes it takes even 15/20 times.What is permanent solution
for this???i even tried kill adb server by adb kill-server.But it was
of no use.

Connection Failure when starting to monitor device 'emulator-5554' :
device (emulator-5554) request rejected:
[2008-12-17 18:13:30 - DeviceMonitor]Failed to start monitoring
emulator-5554
[2008-12-17 18:13:31 - DeviceMonitor]Adb connection Error:An existing
connection was forcibly closed by the remote host
[2008-12-17 18:13:32 - DeviceMonitor]Connection attempts: 1
[2008-12-17 18:13:34 - DeviceMonitor]Connection attempts: 2


--~--~---------~--~----~------------~-------~--~----~

3. HttpClient and POST requests

4. Sliding tabs

5. I want to take a look at source of Dialer, Contacts, et

6. AbstractGDataSyncAdapter

7. Why "requestWindowFeature(Window.FEATURE_LEFT_ICON)" always return false?