2015-08-08 113 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; 

} 
相關問題