簡體   English   中英

Android中的屏幕方向,橫向

[英]screen orientations in Android, landscape

我想知道如何在更改手機方向時修改視圖。 例如,當您以“正常方式”握住手機時,我的應用程序運行正常,但是當您將其移動到橫向位置時,應用程序的外觀就會變得難看:-如何確保牆紙不會與手機一起“旋轉” ,這是我的布局代碼:文件名: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>

如您所見,這只是一個簡單的列表,但我希望背景保持不變。 我為布局和布局區域放置了相同的內容,只是將相同的文件list_event放置了,但是我認為我需要添加一些命令以使背景圖像以不同的方式定向。 我希望你能事先了解我寫的感謝信

在橫向和縱向模式下為視圖創建不同的布局,並將橫向視圖放置在res/layout-land ,將縱向視圖放置在res/layout-port (從技術上講,您只需要layout和layout- {land,port},因為layout是如果未指定方向限定符,則返回。

有關更多信息,請參閱文檔

在您的景觀布局中(請參閱Heiko和TofferJ的答案),使用一幅適合於景觀布局的圖像(具有所需的方向/尺寸)。

有關詳細信息,請參見此處: Android:橫向模式的替代布局xml

或在此處查看Google的教程: http : //developer.android.com/guide/topics/resources/providing-resources.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM