How to resize AlertDialog on the Keyboard display

前端 未结 6 1924
时光取名叫无心
时光取名叫无心 2020-12-05 00:39

I have a AlertDialog box with approximately 10 controls (text and TextView) on it. These controls are in a ScrollView with Alert

6条回答
  •  时光取名叫无心
    2020-12-05 00:58

    If your dialog was an activity using one of the Dialog themes you could effect this behavior by setting the adjustResize flag for the windowSoftInputMode parameter of the activity.

    I'm using:

    android:windowSoftInputMode="adjustResize|stateHidden"
    

    I think you can still use this flag with regular dialogs, but I'm not sure how to apply it. You may have to create your AlertDialog with a custom theme that inherits the right parent theme and also sets that flag, or you might have to use ContextThemeWrappers and stuff.

    Or maybe you can just use Window#setSoftInputMode.

    alertDialog.getWindow().setSoftInputMode(
        WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    

提交回复
热议问题