In this article we will create an Android application which uses different layouts for landscape and portrait views of the device
1. Create an Android project namely “LandPortView”
2. Select Android build target
3. Enter application details
4. res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, MainActivity!</string> <string name="app_name">LandPortViews</string> <string name="str_land">This is landscape view</string> <string name="str_port">This is portrait view</string> </resources>
5. Create a new folder namely “layout-land” under the folder “res”
6. Create a layout file called main.xml in the folder “layout-land” and add the given below code
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_land" android:layout_gravity="center_horizontal" /> </LinearLayout>
7. Create a new folder namely “layout-port” under the folder “res”
8. Create a layout file called main.xml in the folder “layout-port” and add the given below code :
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/str_port" android:layout_gravity="center_horizontal" /> </LinearLayout>
9. Application in execution
10. Download

11. Reference
http://developer.android.com/guide/index.html

I am George Mathew, working as software architect and Android app developer at wptrafficanalyzer.in
You can hire me on hourly basis or on project basis for Android applications development.
For hiring me, please mail your requirements to info@wptrafficanalyzer.in.
My other blogs
store4js.blogspot.com
Thank you so much for very nice and useful post!!
nice post sir…
but when we change orientation from landscape to portrait the view doesnt change ,it leave landscape view only…
If possible plz post suggestion for this issue.
Can you please recheck the issue? Because i am not able to find the issue.