gpt4 book ai didi

BottomSheetBehavior 布局中的 Android RecyclerView

转载 作者:行者123 更新时间:2023-11-29 18:35:33 25 4
gpt4 key购买 nike

问题是 BottomSheetBehavior 进行了滚动,我无法在 RecyclerView 中垂直滚动我的项目。我想先从 RecyclerView 滚动项目

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="view.activity.MyActivity">


<!--my activity views-->

<include layout="@layout/custom_bottom_sheet_view" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>

custom_bottom_sheet_view 的代码是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet_searches"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="56dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp">

<!--view peek-->

</RelativeLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>

最佳答案

试试这个:

mRecycler.setOnTouchListener(new RecyclerView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow NestedScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(true);
break;

case MotionEvent.ACTION_UP:
// Allow NestedScrollView to intercept touch events.
v.getParent().requestDisallowInterceptTouchEvent(false);
break;
}

// Handle RecyclerView touch events.
v.onTouchEvent(event);
return true;
}
});

mRecycler 是你的 RecylerView

关于BottomSheetBehavior 布局中的 Android RecyclerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54516704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com