I am trying a very simple app where I'd like to display a DialogFragment
. However I would like to align the DialogFragment
's right margin with the Activity
's right edge. I used layout gravity to align the Dialog's window to the right and top:
public class MyDialogFragment extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.activity_main, container, false);
getDialog().getWindow().setGravity(Gravity.RIGHT | Gravity.TOP);
return view;
}
}
However there is 'gap' between the DialogFragment
's right edge and the Activity
's right by default. I've tried a few SO posts but none seem to work for me:
Changing position of the Dialog on screen android
Show AlertDialog in any position of the screen
I am trying to anchor my dialog to a particular coordinate pair but I am not successful with this approach. What I'd like to do is simply align the dialog's right margin with the Activity
's right edge.
Here is an image of my issue. Any direction or a solution would be most appreciated.