2015-08-08 37 views
2

我有一个DialogFragment与两个EditText字段和另一个字段与ImageView增加它们下面的值,他们都住在ScrollView是否有SoftInputMode解决方法来显示整个对话框

的问题既不是软键盘调整模式显示了我的整个DialogFragment一次,尽管那里是空间。

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

删除ScrollView表示任一选项都会导致键盘重叠。

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

adjustPanadjustResizeThe result I'd like

回答

1

我发现的唯一的解决办法是改变对话片段本身的窗口选项。显然,在更小的屏幕上,这仍然是一个问题,所以我仍然在寻找更好的答案。

@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; 

} 
相关问题