嵌套滚动:RecyclerView 中的 ListView
Nested scrolling : ListView inside a RecyclerView
我正在构建一个 android 应用程序,现在它有一个主回收器视图(填充了项目,这些项目按 item.xml 布局),并且在每个 item.xml,有一个listView.
我怎样才能在这个列表视图中进行滚动,因为现在应用程序只监听回收器视图的滚动?
我试过下面的行,但它不起作用:
android:nestedScrollingEnabled="true"
非常感谢您的帮助:)!
我是这样解决的:
mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if(rv.getChildCount() > 0) {
View childView = rv.findChildViewUnder(e.getX(), e.getY());
if(rv.getChildPosition(childView) == [listview position]) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
rv.requestDisallowInterceptTouchEvent(true);
}
}
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
});
我正在构建一个 android 应用程序,现在它有一个主回收器视图(填充了项目,这些项目按 item.xml 布局),并且在每个 item.xml,有一个listView.
我怎样才能在这个列表视图中进行滚动,因为现在应用程序只监听回收器视图的滚动?
我试过下面的行,但它不起作用:
android:nestedScrollingEnabled="true"
非常感谢您的帮助:)!
我是这样解决的:
mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if(rv.getChildCount() > 0) {
View childView = rv.findChildViewUnder(e.getX(), e.getY());
if(rv.getChildPosition(childView) == [listview position]) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
rv.requestDisallowInterceptTouchEvent(true);
}
}
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
});