Is it possible by using a DialogFragment
to be able to move it out of the center and place it anywhere on the screen?
tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the DialogFragment. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog.
This method is deprecated. androidx.
Dialog: A dialog is a small window that prompts the user to make a decision or enter additional information. DialogFragment: A DialogFragment is a special fragment subclass that is designed for creating and hosting dialogs.
You can use
getDialog().getWindow().setAttributes(param);
in
onCreateView()
like this
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
getDialog().getWindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
WindowManager.LayoutParams param = getDialog().getWindow().getAttributes();
param.width = LayoutParams.MATCH_PARENT;
param.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE;
param.x = 100;
param.y = 100;
.
.
getDialog().getWindow().setAttributes(p);
.
.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With