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. How to pass response from ksoap to another activity


Can anybody please tell how to pass response from ksoap to another
activity. I have attached the code. Please suggest the required
modifications.Thanks for your help in advance....


import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class medbase extends Activity {
/** Called when the activity is first created. */

protected static final int SEARCH_REQUEST_CODE = 1337;
private static final String SOAP_ACTION = "
private static final String METHOD_NAME = "GetAllIDs";
private static final String NAMESPACE = "";
private static final String URL = "
private Object resultRequestSOAP = null;
public void onCreate(Bundle savedInstanceState)

Button bcmd_opensub = (Button)findViewById(;
bcmd_opensub.setOnClickListener(new OnClickListener()
// @Override
public void onClick(View arg0)

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope
envelope.dotNet = true;
//request.addProperty(PropertyInfo(name, java.lang.String), "arg1");
envelope.setOutputSoapObject( request );
HttpTransportSE transport = new HttpTransportSE(URL);
{, envelope);
catch( IOException exp )
resultRequestSOAP = envelope.getResponse();
catch( SoapFault exp )

String results = resultRequestSOAP.toString();

catch (Exception aE)
aE.printStackTrace ();

Intent iSearchObj = new Intent(medbase.this,
PatientSearch.class); // PatientSearch is the child activity

// We use SUB_ACTIVITY_REQUEST_CODE as an 'identifier'
medbase.this.startActivity(iSearchObj );

2. Bad news on the Agroa....

Hope no-one else is looking to roll out a QVGA device.


Funky Android Limited is registered in England & Wales with the 
company number  6741909. The registered head office is Kemp House, 
152-160 City Road, London,  EC1V 2NX, UK. 

The views expressed in this email are those of the author and not 
necessarily those of Funky Android Limited, it's associates, or it's 


3. Problem about android SDK 1.0 porting on IMX31 board (No pending application record for pid 0)

4. How can multiple applications running at the same time

5. Muticast Socket

6. Problem in Viewing table - sdk1.0

7. tslib is having some issues