gpt4 book ai didi

android - 是否有 SoftInputMode 解决方法来显示整个对话框

转载 作者:行者123 更新时间:2023-11-29 01:29:45 28 4
gpt4 key购买 nike

我有一个带有两个 EditText 字段的 DialogFragment 和另一个带有 ImageView 的字段以增加其在这些下方的值,它们都位于 ScrollView

问题是 soft keyboard 的调整模式都不会一次显示我的整个 DialogFragment,尽管有空间。

adjustResize 导致 ScrollView 调整大小并隐藏底行。 adjustpan 保持 ScrollView 大小不变,但 软键盘 与底行重叠。

删除 ScrollView 意味着任一选项都会导致键盘重叠。

我希望 DialogFragment 在不调整大小的情况下向上移动屏幕。我能做到吗?理想情况下,我希望将 ScrollView 保留在我的 Layout 中,以更好地支持非常小的屏幕。

adjustPan adjustResize The result I'd like

最佳答案

我找到的唯一解决方案是更改对话框 fragment 本身的窗口选项。显然,在较小的屏幕上这仍然是一个问题,所以我仍在寻找更好的答案。

@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {

//I was using android.R.style.Theme_Translucent_NoTitleBar for another issue
//but I don't think the theme makes any difference to how the window is laid out
//that is relevant to the below code
Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
... //Do your usual stuff here
dialog.getWindow().setContentView(...);

final WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.TOP; //this is the important part
dialog.setCanceledOnTouchOutside(false);

return dialog;

}

关于android - 是否有 SoftInputMode 解决方法来显示整个对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31895774/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com