在Android中禁用SlidingDrawer下的图层

发布于 2024-11-06 05:29:26 字数 424 浏览 0 评论 0原文

我发现了一些关于这个主题的问题,并且尝试了解决方案,但我似乎无法得到正确的答案。我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

木槿暧夏七纪年 2024-11-13 05:29:26

我终于通过执行以下操作解决了这个问题:

//sliderdrawer close
private OnDrawerCloseListener onClick_DrawerClosed = new OnDrawerCloseListener() {
    @Override
    public void onDrawerClosed() {
        _slideDrawer.setClickable(false);
    }
};

//sliderdrawer open
private OnDrawerOpenListener onClick_DrawerOpened = new OnDrawerOpenListener() {
    @Override
    public void onDrawerOpened() {
        _slideDrawer.setClickable(true);
    }
};

I finally got around this by doing the following type of thing:

//sliderdrawer close
private OnDrawerCloseListener onClick_DrawerClosed = new OnDrawerCloseListener() {
    @Override
    public void onDrawerClosed() {
        _slideDrawer.setClickable(false);
    }
};

//sliderdrawer open
private OnDrawerOpenListener onClick_DrawerOpened = new OnDrawerOpenListener() {
    @Override
    public void onDrawerOpened() {
        _slideDrawer.setClickable(true);
    }
};
凉薄对峙 2024-11-13 05:29:26

尝试在滑动抽屉内容组件上设置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.

日记撕了你也走了 2024-11-13 05:29:26

设置可点击完全消除了到后面窗口的任何传递,而程序方法将允许下面的项目在抽屉关闭后看到点击。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文