【发布时间】:2014-10-15 17:32:21
【问题描述】:
在 Eclipse-Android 中;我创建了两个 xml 文件;一张是纵向的,一张是横向的。在教程中,讲师只需将相同的 xml 纵向内容添加到横向 xml 文件中,当应用程序运行时,视图在纵向和横向模式下都正确显示。但是,我尝试用列表视图做同样的事情,但列表视图不会旋转到横向。我已经使用 android:orientation="horizontal" 将方向设置为水平,并且在图形布局中我可以看到横向的内容,但是当应用程序运行时,纵向列表视图内容不会旋转到横向。我可能做错了什么?
这里是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>
【问题讨论】: