如何在键盘显示上调整 AlertDialog 的大小 [英] How to resize AlertDialog on the Keyboard display

查看:30
本文介绍了如何在键盘显示上调整 AlertDialog 的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 AlertDialog 框,上面有大约 10 个控件(文本和 TextView).这些控件位于带有 AlertDialogScrollView 中,另外还有 2 个正负按钮.我遇到的问题是当软键盘弹出时,两个按钮隐藏在键盘后面.

I have a AlertDialog box with approximately 10 controls (text and TextView) on it. These controls are in a ScrollView with AlertDialog, plus I got 2 buttons positive and negative. The issue I have is when the soft keyboard pops up the two buttons are hidden behind the keyboard.

我在内部视图或对话框中寻找类似重绘功能的东西.下面是我正在谈论的屏幕截图.

I was looking for something like redraw function on my inner View or the dialog box. Below is the screen shot of what I am talking about.

推荐答案

如果您的对话框是使用 Dialog 主题之一的活动,您可以通过为 adjustResize 设置标志来影响此行为>windowSoftInputMode 活动的参数.

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.

我正在使用:

android:windowSoftInputMode="adjustResize|stateHidden"

我认为您仍然可以在常规对话框中使用此标志,但我不确定如何应用它.您可能必须使用自定义主题创建 AlertDialog,该主题继承了正确的父主题并设置了该标志,或者您可能必须使用 ContextThemeWrappers 和其他东西.

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.

或者也许你可以只使用 Window#setSoftInputMode.

Or maybe you can just use Window#setSoftInputMode.

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

这篇关于如何在键盘显示上调整 AlertDialog 的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆