【发布时间】:2015-08-22 14:42:19
【问题描述】:
我有一个主布局,包括 2 个布局,一个包含一个 FrameLayout,里面有一个 Fragment。另一个带有包含 ListView 的 LinearLayout。这就是我的主要布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/map_layout" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"></include>
<include layout="@layout/list_layout" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="6"></include>
</LinearLayout>
</ScrollView>
</LinearLayout>
第一个 Fragment 包含一个地图,第二个包含一个带有自己的 listAdapter 的自定义 ListView。
所以这是我的问题,我知道将 ListView 放在 ScrollView 中有点棘手。但是在我的 ListFragment.java 的 onCreateView 中我放了这个:
list.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
但 ListView 不断抓住滚动。一会儿,ScrollView的bug,把地图和文件列表放了一个无限的ScrollView。
我该怎么做才能让它发挥作用?
【问题讨论】:
-
您正在尝试做一些平台不支持的事情,这是一个很好的限制(IT DEFO 不是 BUG)并且它不起作用。你的问题是什么?
-
我该怎么做才能让它工作?
-
您不要将 ScrollView 放在 ListVIew 中,平台不支持。请尝试使用 CoordinatorLayout。
-
它是一个 ScrollView 内的 ListView。但我会看看如何使用 CoordinatorLayout。
-
ListView inside ScrollVIew 或 ScrollView inside ListView 没有区别。它们都不支持嵌套滚动,并且嵌套滚动不适用于它们。