screen orientations in Android, landscape

vallllll picture vallllll · May 6, 2011 · Viewed 10.1k times · Source

I would like to know how to modify views when the phone orientation is changed. Like for example my app works fine when you hold the phone "the normal way" but when you moove it into the landscape position then the app appearance becomes ugly: -how to make sure the wallpaper doesn't "turn" together with the phone, here is my layout code: name of file: list-event.xml

<?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">
   <ListView android:id="@android:id/list"
  android:layout_height="wrap_content" 
  android:layout_width="fill_parent" 
  android:background="@drawable/fon2"></ListView>
</LinearLayout>

As you can see it's just a simple list but I would like the background to stay the same. I put the same content for layout and layout-land I just put this same file list_event but I think I need to add some comand for the background image to be oriented in diferent way. I hope you understand what I wrote thanks in advance

Answer

Heiko Rupp picture Heiko Rupp · May 6, 2011

Create different layouts for your views in landscape and portrait mode and put the landscape ones in res/layout-land and the portrait ones in res/layout-port (technically you only need layout and layout-{land,port} as layout is the fallback if no orientation qualifier is given).

See the docs for more info.