【发布时间】:2013-08-20 18:40:20
【问题描述】:
我正在尝试在 android 中将 ListView 放在 ScrollView 下方。我试着把它们放在像这样的LineaLayout 中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/marketDetailScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
...
</ScrollView>
<ListView android:id="@android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#FFF"/>
</LinearLayout>
并且ListView 没有显示。我还尝试将其放入 RelaviteLayout 中,但仍然没有。我可以以某种方式在ScrollView 下有一个ListView 吗?
只是添加一些东西。我不想分割我的屏幕,这样我就有一半是ScrollView,另一半是ListView。我希望用户向下滚动显然大于屏幕尺寸的ScrollView,然后应该启动ListView
【问题讨论】:
-
修复滚动视图的高度.. like
android:layout_height="100dip" -
你可以让listview将scrollview内的视图作为页眉或页脚添加到listview(没有scrollview)或指定一个固定高度的scroll view并在它下面添加listview
-
在您的滚动视图中,
android:layout_height="fill_parent"表示您的滚动视图会将所有空间都放到底部,因此您的 ListView 没有更多空间了。 -
您正在使用
LinearLayout,并且您将您的ListView放在ScrollView下方,另外您将ScrollView的width和height设置为fill_parent所以@ 987654342@ 将覆盖并获得ListView的显示,如果您希望您的ListView出现,例如为您的ScrollView、200dp设置特定大小。希望这会有所帮助。