Android之解决点击PopupWindow外部不消失并且不穿透事件
生活随笔
收集整理的這篇文章主要介紹了
Android之解决点击PopupWindow外部不消失并且不穿透事件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 問題
需要實現PopupWindow內部可以點擊,但是外部點擊不會消失
2 初步解決辦法
設置PopupWindow的mFocusable屬性mOutsideTouchable屬性,我們知道如果我們不想穿透事件,也就是說,不想出現點擊Popuowindow外部的文本框或者按鈕生效,我們需要獲取Popuowindow的焦點,也就是設置mFocusable值為true
也就是setFocusable( true ),然后我們分析mOutsideTouchable的設置函數解釋
/*** <p>Controls whether the pop-up will be informed of touch events outside* of its window. This only makes sense for pop-ups that are touchable* but not focusable, which means touches outside of the window will* be delivered to the window behind. The default is false.</p>** <p>If the popup is showing, calling this method will take effect only* the next time the popup is shown or through a manual call to one of* the {@link #update()} methods.</p>** @param touchable t 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Android之解决点击PopupWindow外部不消失并且不穿透事件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android之Activity ***
- 下一篇: Android之library clas