Android中的屏幕方向,风景

val*_*lll 2 android landscape background-image landscape-portrait

我想知道如何在更改手机方向时修改视图.例如,当你按住手机"正常方式"时,我的应用程序工作正常,但当你将它移动到横向位置时,应用程序外观变得丑陋: - 如何确保壁纸不会与手机一起"转动" ,这是我的布局代码:文件名: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>
Run Code Online (Sandbox Code Playgroud)

你可以看到它只是一个简单的列表,但我希望背景保持不变.我为布局和布局添加了相同的内容 - 我只是将同一个文件列为list_event,但我认为我需要为背景图像添加一些命令,以便以不同的方式进行定向.我希望你提前了解我写的内容

Hei*_*upp 6

在横向和纵向模式下为视图创建不同的布局,并将横向视图和纵向视图放在res/layout-land一起res/layout-port(技术上,您只需要布局和布局 - {land,port},因为如果没有给出方向限定符,布局就是后退).

有关详细信息,请参阅文档.