为什么我可以点击“隐藏"Android的最底层? [英] Why am I able to click "behind" the bottomsheet in Android?

查看:63
本文介绍了为什么我可以点击“隐藏"Android的最底层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的活动中有一个 BottomSheet .

我正在调用 behavior.setState(BottomSheetBehavior.STATE_EXPANDED); 来显示底部工作表,它工作正常,但是我遇到的问题是我可以以某种方式单击我的空白处触发底部视图后面的视图的 onClick 事件.

I'm calling behavior.setState(BottomSheetBehavior.STATE_EXPANDED); to show the bottom sheet and it works fine, but the problem I have is that I can somehow click on the empty space of my bottom sheet to trigger onClick event of a view that is behind the bottom sheet.

是否有防止这种情况发生的方法?

Is there a way to prevent this from happening?

推荐答案

一个简单的解决方案是添加

A simple solution is to add the

android:clickable ="true"

android:clickable="true"

归因于您用于底部工作表的布局.这样,它将捕获所有点击,而不会让它们流血.您不必为此设置 onClick 方法,因为您无需处理它们.

attribute to the layout that you are using for your bottom sheet. That way it will capture all clicks, and not let them bleed through. You do not have to set an onClick method for it, as you have no need to handle them.

这篇关于为什么我可以点击“隐藏"Android的最底层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆