2

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

Leon Armstrong
  • 1,285
  • 3
  • 16
  • 41
vallllll
  • 2,731
  • 6
  • 43
  • 77

3 Answers3

6

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.

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
1

In your landscape layout (see Heiko's and TofferJ's answers), use another image, suited for the landscape layout (with the desired orientation/dimensions).

compostus
  • 1,178
  • 10
  • 13
  • 5
    You can also provide alternative images in your res/drawable-port res/drawable-land directories. Then you don't need to reference images with different names in your layout.xml, android automatically chooses the right ones according to current orientation. Here's an example: http://developer.android.com/resources/samples/Home/res/index.html – compostus May 06 '11 at 13:12
0

See this post here för details: Android: alternate layout xml for landscape mode

Or check Google's tutorial here: http://developer.android.com/guide/topics/resources/providing-resources.html

Community
  • 1
  • 1
TofferJ
  • 4,678
  • 1
  • 37
  • 49