【问题标题】:How to respond BottomSheetDialogFragment's outside touch events in Android如何在Android中响应BottomSheetDialogFragment的外部触摸事件
【发布时间】:2018-11-05 21:29:08
【问题描述】:

当我在 BottomSheetDialogFragment 之外触摸时,我想防止对话框关闭并在对话框后面响应触摸事件,所以我在 BottomSheetDialogFragment 类中这样做:

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View dialogView = inflater.inflate(R.layout.poi_result_bottom_dialog, container, false);
    this.getDialog().setCanceledOnTouchOutside(false);
    return dialogView;
}

但是,我发现如果我设置了“setCanceledOnTouchOutside(false)”,当我在对话框外触摸时,对话框下的活动无法响应触摸事件。

【问题讨论】:

  • 这是设计使然!为什么你想要它不同。
  • 我是新手,只知道这个方法。有什么方法吗?

标签: android ontouchlistener


【解决方案1】:

您不应该使用BottomSheetDialog。您想要的被称为持久底页。通过使用嵌入式View 并设置BottomSheetBehavior,在androidhive.info 的说明中有很好的描述。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多