开发者

screen orientations in Android, landscape

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="f开发者_Go百科ill_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


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜