How to create a floating touchable activity that still allows to touch native controls outside of its borders?

后端 未结 2 683
生来不讨喜
生来不讨喜 2020-12-30 14:32

What I am trying to achieve is best explained by the scheme I made with mspaint:

I have tried to set FLAG_NOT_TOUCH_MODAL which by the descript

2条回答
  •  伪装坚强ぢ
    2020-12-30 15:04

    Set a Dialog theme on the Activity in your manifest. For example:

    android:theme="@android:style/Theme.Dialog"
    

    Then set the following Window parameters in onCreate():

    public void setWindowParams() {
        WindowManager.LayoutParams wlp = getWindow().getAttributes();
        wlp.dimAmount = 0;            
        wlp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
        getWindow().setAttributes(wlp);     
    }
    

提交回复
热议问题