在Android中禁用SlidingDrawer下的图层
我发现了一些关于这个主题的问题,并且尝试了解决方案,但我似乎无法得到正确的答案。我有一个TableLayout作为RelativeLayout中的第一个子元素,一个SlidingDrawer作为第二个子元素。幻灯片工作正常,但是当抽屉打开时单击抽屉会进入抽屉下的物品。
我尝试在滑块的打开处添加一个带有“return true”的 ontouch 侦听器,但似乎所做的一切都不允许我打开抽屉。此外,如果抽屉打开,“将”被抽屉覆盖的任何东西都是不可点击的。
如果我将“return true”更改为
if (slidingDrawer.isOpened()) 返回真; 别的 返回假;
这给我带来了一些问题。当抽屉打开并且我无法单击进入下层时,我也无法单击抽屉上的任何内容或单击手柄来关闭抽屉。
我不确定我错过了什么。我将不胜感激任何帮助。
I've found a few questions on this topic and i've tried the solutions, but I can't seem to get it right. I have a TableLayout as the first child in a RelativeLayout and a SlidingDrawer as the second child. The slide works fine, but clicking on the drawer when it's open goes through to the items under the drawer.
I've tried adding an ontouch listener with a "return true" to the opening of the slider, but all that seems to do is not allow me to open the drawer. Also, anything that "would" be covered by the drawer if it was open, is unclickable.
If I change the "return true" to a
if (slidingDrawer.isOpened())
return true;
else
return false;
this gives me a couple of problems. While the drawer opens and i cannot click through to the lower layer, I also cannot click anything on the drawer or click the handle to close the drawer.
I'm not sure what I'm missing. I'd appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我终于通过执行以下操作解决了这个问题:
I finally got around this by doing the following type of thing:
尝试在滑动抽屉内容组件上设置
android:clickable="true"
,而不是在父抽屉组件上切换它。对我有用,不需要代码来监听状态变化。Try setting
android:clickable="true"
on the sliding drawer content component rather than toggling it on the parent drawer component. Works for me and doesn't require code to listen for the state change.设置可点击完全消除了到后面窗口的任何传递,而程序方法将允许下面的项目在抽屉关闭后看到点击。
Setting the clickable completely removes any pass through to the window behind, whereas the procedural method, will allow the item below to see clicks once the drawer is closed.