Android notex Q9: pop up settings can be touched

If it is set to true, it will still be dropped by miss when clicking outside. Why?

 * <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 true if the popup should receive outside
 * touch events, false otherwise
 * @see #isOutsideTouchable()
 * @see #isShowing()
 * @see #update()
public void setOutsideTouchable(boolean touchable) {
mOutsideTouchable = touchable;

According to the interpretation of the official API, when focusable = false, setting setoutsidetouchable is meaningful. If focusable = true is set, it is meaningless, because focusable = true will take away the focus event. If outside can’t get the focus, then the touch of outside is useless.

So how to set focusable = true and keep external clicks from being ignored?

var isForceDismiss = false
override fun dismiss() {
if (isForceDismiss) {
isForceDismiss = true

Rewrite the Miss method of popupwindow and make a logical judgment

Read More: