【问题标题】:Landscape Layout xml does not rotate content横向布局 xml 不旋转内容
【发布时间】:2014-10-15 17:32:21
【问题描述】:

在 Eclipse-Android 中;我创建了两个 xml 文件;一张是纵向的,一张是横向的。在教程中,讲师只需将相同的 xml 纵向内容添加到横向 xml 文件中,当应用程序运行时,视图在纵向和横向模式下都正确显示。但是,我尝试用列表视图做同样的事情,但列表视图不会旋转到横向。我已经使用 android:orientation="horizo​​ntal" 将方向设置为水平,并且在图形布局中我可以看到横向的内容,但是当应用程序运行时,纵向列表视图内容不会旋转到横向。我可能做错了什么?

这里是xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".Activity" >

<TextView
    android:id="@android:id/empty"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="@string/no_data" /> <!-- Will display when There is no data. Need to Add Name/Value to xml value string.xml file as well -->

<ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:orientation="horizontal" >
</ListView>

【问题讨论】:

    标签: xml landscape


    【解决方案1】:

    这可能是模拟器的问题,而不是您的代码。

    https://code.google.com/p/android/issues/detail?id=61671

    Google 刚刚发布了(10 天前,2015 年 3 月 12 日)其 Android SDK (API 22) 的更新,该更新显然解决了这个问题(您可以旋转模拟器屏幕,但它仍处于纵向模式)。

    直接解决方法是为您的模拟器使用不同的目标 SDK API 级别。

    在 Eclipse 菜单中,Window -> Android Virtual Device Manager。

    使用 API 19 之外的其他 目标编辑现有模拟器(或创建新模拟器)。

    API 18 工作正常。我假设 API 级别 22(根据谷歌的固定版本,在上面的链接中)也可以工作。

    当您按 Ctrl + F11(在 Mac 上为 Ctrl + fn + F11)时,模拟器应该旋转,您的应用程序用户界面也应该旋转。

    【讨论】:

    • 抱歉回复晚了。事实上,这就是问题所在。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    • 2014-01-29
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 1970-01-01
    相关资源
    最近更新 更多