简体   繁体   English

Android-下拉通知抽屉时ImageButton失去按下状态

[英]Android - ImageButton Loses Pressed State When Notification Drawer is Pulled Down

I am losing the pressed state of my ImageButton when the notification drawer is dragged down form the top. notification抽屉从顶部向下拖动时,我失去了ImageButton的按下状态。

I'm not sure why this is happening? 我不确定为什么会这样吗? I'm currently using onSaveInstanceState and onRestoreInstanceState to ensure that the ImageButtons state get's saved and restored. 我目前正在使用onSaveInstanceStateonRestoreInstanceState来确保ImageButtons状态得到保存和恢复。

For the most part it does it's job, the only issue I am having is when the notification drawer get's pulled down. 在大多数情况下,它都能完成工作,我唯一遇到的问题是notification抽屉被拉下时。 Does anyone know why this is causing my ImageButton to lose it's pressed state and how to get around it? 有谁知道为什么这会导致我的ImageButton失去按下状态以及如何解决?

Looks like the only way to get to detect the notification drawer is using 'onWindowFocusChanged'. 看起来要检测通知抽屉的唯一方法是使用“ onWindowFocusChanged”。 This returns false when the drawer is pulled down and true when it get's pulled back up again. 当抽屉被拉下时,它返回false;当抽屉被再次拉回时,它返回true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM