How can I display a dialog above the keyboard

后端 未结 4 1612
野性不改
野性不改 2021-02-09 17:48

I\'m a newbie with android, I write an application which using the Dialog to display data when user select on one thing. This is how the dialog looks:

https://docs.googl

相关标签:
4条回答
  • 2021-02-09 18:24

    Have you tried ths one?

    Worked for me:

    http://developer.android.com/reference/android/view/Window.html#setSoftInputMode(int).

    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    
    0 讨论(0)
  • 2021-02-09 18:27

    You may need to set dialog's width and height manually in order to make soft input mode work like this:

        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.MATCH_PARENT;
        params.gravity = Gravity.CENTER;
        window.setAttributes(params); 
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE ); 
    
    0 讨论(0)
  • 2021-02-09 18:31
     AlertDialog dialog = new AlertDialog.Builder(this).create();
     dialog.show();
     Window window = dialog.getWindow();
     window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
     window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    
    0 讨论(0)
  • 2021-02-09 18:34

    create a Xml file name style.xml

    <style name="FullHeightDialog" parent="android:style/Theme.Dialog">
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowSoftInputMode">stateUnchanged</item>
            <item name="android:windowBackground">@color/dialog_transparent</item>
    </style>
    

    then Implement

    this works for me hoping it will work for you also.

    final Dialog dialog = new Dialog(this , R.style.FullHeightDialog);
    

    and also do changes in your manifest file

    android:windowSoftInputMode="adjustResize|adjustPan" 
    
    0 讨论(0)
提交回复
热议问题