timed modeless dialog

前端 未结 3 1431
礼貌的吻别
礼貌的吻别 2020-12-05 01:06

Is there any way to show a modeless dialog--a dialog that allows the user to interact with whatever was on the screen before the dialog but also allows the user to interact

3条回答
  •  攒了一身酷
    2020-12-05 01:58

    My implementation which was a little more hackish but also allows button presses to be caught by background window

    _wm = this.getWindowManager();
    LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    _view = layoutInflater.inflate(R.layout.notification, null);
    
    _params = new WindowManager.LayoutParams();
    _params.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    _params.width = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    _params.flags = 
        // this is to keep button presses going to the background window
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
        // this is to enable the notification to recieve touch events
        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
    // background transparant
    _params.format = PixelFormat.TRANSLUCENT;
    _gravity = Gravity.TOP;//Gravity.BOTTOM;
    
    _wm.addView(_view, _params);
    

提交回复
热议问题