如何在 Android 中禁用 SlidingDrawer 后面的视图? [英] How can I disable a view behind my SlidingDrawer in Android?

查看:24
本文介绍了如何在 Android 中禁用 SlidingDrawer 后面的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SlidingDrawer,它会从屏幕底部弹出并填充屏幕大约 80%.即使 SlidingDrawer 视图处于焦点,仍然可以单击 SlidingDrawer 后面的视图中的项目、按钮和其他元素.当 SlidingDrawer 处于活动状态/拉起/聚焦时,我想禁用它后面的整个视图,这样它就无法接收点击和触摸.有没有禁用整个视图的好方法?我尝试过 setEnable(false) 和 setClickable(false) 但它们都不起作用.

I have a SlidingDrawer that pops up from the bottom of the screen and fills the screen about 80%. Even though the SlidingDrawer view is in focus, it is still possible to click on items, buttons and other elements in the view that is behind the SlidingDrawer. When SlidingDrawer is active/pulled up/in focus, I want to disable the entire view behind it so it will not be able to recieve clicks and touches. Is there a good way to disable an entire view? I have tried setEnable(false) and setClickable(false) but neither of them work.

帮助?

推荐答案

这里有一个方法可以解决这个问题(我也需要一个解决方案) - 获取保存内容的 linearLayout 并添加一个单击侦听器.让点击监听器对点击做出响应(扔掉,随便)——然后这会阻止它传播到滑动抽屉下面的视图——它对我有用——它不会阻止抽屉中的其他项目.

Here's a way to get around this problem (I needed a solution also) - grab the linearLayout that holds the contents and add a click listener. Have the click listener respond to clicks (throw away, whatever) - and this then stops it propagating to the view below the sliding drawer - it works for me - and it doesn't block the other items in the drawer.

这篇关于如何在 Android 中禁用 SlidingDrawer 后面的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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