当前位置:网站首页>Bottomsheetdialogfragment conflicts with listview recyclerview Scrollview sliding
Bottomsheetdialogfragment conflicts with listview recyclerview Scrollview sliding
2022-04-23 07:10:00 【Zhang Hailong_ China】
1. The phenomenon :BottomSheetDialogFragment You can slide up and down through gestures , frequently-used ListView RecyclerView ScrollView Can also slide up and down , There will be some conflict problems , such as ScrollView When you want to slide down ,ScrollView The content doesn't slide , however BottomSheetDialogFragment It was pulled down and closed .
2. Source code analysis
open BottomSheetDialog Source code :
private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) {
final FrameLayout container = (FrameLayout) View.inflate(getContext(),
R.layout.design_bottom_sheet_dialog, null);
final CoordinatorLayout coordinator =
(CoordinatorLayout) container.findViewById(R.id.coordinator);
if (layoutResId != 0 && view == null) {
view = getLayoutInflater().inflate(layoutResId, coordinator, false);
}
FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet);
mBehavior = BottomSheetBehavior.from(bottomSheet);
mBehavior.setBottomSheetCallback(mBottomSheetCallback);
mBehavior.setHideable(mCancelable);
if (params == null) {
bottomSheet.addView(view);
} else {
bottomSheet.addView(view, params);
}
//... Omit
return container
Incoming View Will eventually be add Into one FrameLayout Of bottomSheet in , And then through bottomSheet To instantiate a BottomSheetBehavior, And then give this mBehavior Set up a mBottomSheetCallback, Let's see what it is :
private BottomSheetBehavior.BottomSheetCallback mBottomSheetCallback
= new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet,
@BottomSheetBehavior.State int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
cancel();
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
};
3. Solution :
3.1 Method 1: rewrite BottomSheetCallback The logic of judgment in
private BottomSheetBehavior.BottomSheetCallback mBottomSheetCallback
= new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet,
@BottomSheetBehavior.State int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {// When judged as drag down behavior , Then the forced setting status is expanded
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED );
}
LogUtil.e(TAG, "onStateChanged——>" + newState);
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
LogUtil.e(TAG, "onSlide——>" + slideOffset);
}
};
3.2 Method 2 : Direct, simple and rough :
Just in RecyclerView ListView A layer of outer covering NestedScrollViewl, If it was ScrollView Replace with NestedScrollViewl
版权声明
本文为[Zhang Hailong_ China]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230607201372.html
边栏推荐
- mysql和pg库遇到冲突数据时的两种处理方式
- npm ERR code 500解决
- iTOP4412 FramebufferNativeWindow(4.0.3_r1)
- 杂七杂八的学习
- 組件化學習
- Encapsulate a set of project network request framework from 0
- org.xml.sax.SAXParseException; lineNumber: 141; columnNumber: 252; cvc-complex-type.2.4.a: 发现了以元素 ‘b
- How does thanos configure different data retention durations for different tenants
- Binder机制原理
- RAC环境alert日志报错Drop transient type: SYSTP2JW0acnAurDgU1sBqMBryw==的排查
猜你喜欢
随机推荐
oracle清除sql的缓存
Itop4412 kernel restarts repeatedly
mysql和pgsql时间相关操作
Tiny4412 HDMI显示
Explore how @ modelandview can forward data and pages through the source code
MySQL笔记2_数据表
Apprentissage par composantes
js时间获取本周一、周日,判断时间是今天,今天前、后
Dolphinscheduler源码包src.tar.gz解压问题
MySQL笔记1_数据库
oracle中生成32位uuid
Abnormal record-15
oracle视图相关
19C RAC修改VIP及SCANIP步骤-同网段
JS 比较2个数组中不同的元素
oracle 修改默认临时表空间
Abnormal record-11
Information:2021/9/29 10:01 - Build completed with 1 error and 0 warnings in 11s 30ms Error异常处理
Research on alertmanager repeated / missing alarm phenomenon and two key parameters_ Wait and group_ Interpretation of interval
oracle undo使用率高问题处理