How to draw view on top of soft keyboard like WhatsApp?

后端 未结 7 785
一个人的身影
一个人的身影 2020-12-07 19:26

I want to know how it\'s possible to add View on top of Keyboard like WhatsApp and Hangout. In chat screen, they insert emoticons view on top of the opened soft

相关标签:
7条回答
  • 2020-12-07 19:55

    After a heavy time of research and try-and-error, I've found another solution similar to the one of Chirag Jain above, but using a custom Dialog.

        mDialogKeyboard = new Dialog(this,android.R.style.Theme_NoTitleBar);
        mDialogKeyboard.setContentView(R.layout.your_custom_layout);
        mDialogKeyboard.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        mDialogKeyboard.getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
        mDialogKeyboard.getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        mDialogKeyboard.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    
        WindowManager.LayoutParams lp=mDialogKeyboard.getWindow().getAttributes();    
        lp.width=WindowManager.LayoutParams.MATCH_PARENT;
        lp.height=mSoftKeyboardHeight;
        lp.gravity=Gravity.BOTTOM | Gravity.LEFT;
        lp.dimAmount=0;
    

    Despite the fact that Chirag Jain answer seems to be more clean, I'll post this here for have an alternative method.

    0 讨论(0)
提交回复
热议问题