android– 当片段中的键盘打开时,警报对话框不会向上移动

android– 当片段中的键盘打开时,警报对话框不会向上移动,第1张

概述我已经在片段中动态创建了一个警告对话框.它有一个编辑文本和一个按钮.我的问题是当用户专注于编辑文本键盘打开时,它的隐藏对话框按钮.我的对话框没有移动到顶部.privatevoidAlertEditMode(finalMyIshVomyIshVo){finalLinearLayoutlinearLayout=newLinearLayout(ge

我已经在片段中动态创建了一个警告对话框.它有一个编辑文本和一个按钮.我的问题是当用户专注于编辑文本键盘打开时,它的隐藏对话框按钮.我的对话框没有移动到顶部.

private voID AlertEditMode(final MyIshVo myIshVo) {    final linearLayout linearLayout=new linearLayout(getContext());    final EditText edittext = new EditText(getContext());    linearLayout.LayoutParams layoutParams =new linearLayout.LayoutParams(linearLayout.LayoutParams.WRAP_CONTENT,linearLayout.LayoutParams.WRAP_CONTENT);    layoutParams.setmargins(50,0,50,0);    edittext.setLayoutParams(layoutParams);    linearLayout.addVIEw(edittext);    final AlertDialog dialog = new AlertDialog.Builder(getContext())            .setVIEw(linearLayout)            .setTitle("Instant Share")            .setPositivebutton(androID.R.string.ok, null) //Set to null. We overrIDe the onclick            .setNegativebutton(androID.R.string.cancel, null)            .create();    // relativeLayout.getwindow().setSoftinputMode(WindowManager.LayoutParams.soFT_input_ADJUST_PAN);    edittext.setText(myIshVo.getMish_name());    edittext.setSelection(edittext.getText().length());    dialog.setonShowListener(new DialogInterface.OnShowListener() {        @OverrIDe        public voID onShow(final DialogInterface dialog) {            button button = ((AlertDialog) dialog).getbutton(AlertDialog.button_POSITIVE);            button.setonClickListener(new VIEw.OnClickListener() {                @OverrIDe                public voID onClick(VIEw vIEw) {                    String ish_Title = edittext.getText().toString().trim();                    String instant_share_ID=myIshVo.getMinstant_share_ID();                    if(ish_Title==null || ish_Title.equalsIgnoreCase("") || ish_Title.contains("<") || ish_Title.contains("\") ){                        //showToastMessage("Title should not be Empty");                        edittext.setError("Please enter valID Title.");                    }else{                        presenter.setEditIsh(ish_Title,instant_share_ID);                        dialog.dismiss();                    }                }            });        }    });    dialog.show();   // dialog.getwindow().setSoftinputMode(WindowManager.LayoutParams.soFT_input_ADJUST_RESIZE);}

我已经尝试将adjustresize赋予活动并动态给出

getwindow().setSoftinputMode(WindowManager.LayoutParams.soFT_input_ADJUST_RESIZE);

但这两种解决方案都不起作用.其他解决方案请提前表示感谢.

[![查看图片] [1]] [1]

解决方法:

当显示AlertDialog的Activity具有半透明状态栏主题时,我遇到了这个问题.

因此,不是使用使用上下文主题的经典AlertDialog.Builder(context)初始化构建器,而是显式传递没有半透明状态栏的对话框主题:

AlertDialog.Builder(context, androID.R.style.theme_DeviceDefault_light_Dialog_NoActionbar)

我选择了这个主题,因为它确保了与棒棒糖前设备的兼容性,但是像androID.R.style.theme_Material_Dialog这样的其他设备也可以做到这一点.

总结

以上是内存溢出为你收集整理的android – 当片段中的键盘打开时,警报对话框不会向上移动全部内容,希望文章能够帮你解决android – 当片段中的键盘打开时,警报对话框不会向上移动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1112483.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存