I'm having some issues with an custom DialogFragment that is displayed Fullscreen. This dialog has content that is scrollable and has an autocompletetextview.
Initially the dialog is displayed with an margin at the top - set programmatically as an transparent view at the top of the layout content. As soon as the autocompletetextview is focused, this margin is reduced to 0 (thus giving the illusion that the dialog is getting in fullscreen mode). At this moment the keyboard is also showed.
Currently, the keyboard reduced the size of the dialog and an button that is on the dialog is moved up, above the keyboard. This creates an issue, because as soon as the autocompletetextview looses focus, the dialog is resized and because of the keyboard resize also an flicker is created: they keyboard is hidden -> the dialog is moved at the bottom -> the dialog resizes to fullscreen -> the dialog resisez to initial size
Current creation of the dialog:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
if (!hasTitle()) {
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
// the content
//final RelativeLayout root = new RelativeLayout(getActivity());
//root.setLayoutParams(
// new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
//dialog.setContentView(root);
if (position != null) {
WindowManager.LayoutParams windowParams = dialog.getWindow().getAttributes();
windowParams.x = position.x;
windowParams.y = position.y;
dialog.getWindow().setAttributes(windowParams);
} else {
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(hasTitle() ? Color.WHITE : Color.TRANSPARENT));
dialog.getWindow().setGravity(Gravity.TOP | Gravity.START);
return dialog;
}
This works partially, as the dialog is not filling the width, it is a lot smaller.
Something does fix this, but it creates another issue:
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_DeviceDefault_DialogWhenLarge_NoActionBar);
}
But this will affect how the background of the dialog looks like and I can't seem to be able to change it from the dialog creation method.
STYLE_NO_FRAME
. – Puklich