Android: How to show AlertDialog in PIP mode?

354 views Asked by At

Whenever there is an error we are showing AlertDialog to inform user. But when in PIP mode this dialog is rendered inside PIP window as it can be seen in attached screenshots. Is there any way to show proper alert AlertDialog out side PIP window?

enter image description here

1

There are 1 answers

0
TestTest On

I had a similar problem while exiting pip and entering back to the main activity while a dialog was showing. When the user came back to the application the dialog was enlarged and the user was not able to close the dialog (he needed to go back and forth just to close it). I found a simple fix to my problem (hopefully it will help in your case as well) What you need to do is to adjust the bounderies of the dialog.

When you create AlertDialog or DialogFragment override the onShow() function

@Override
public AlertDialog show() {
   AlertDialog dialog =  super.show();

   int width =  WindowManager.LayoutParams.WRAP_CONTENT;
   int height =  WindowManager.LayoutParams.WRAP_CONTENT;

   dialog.getWindow().setLayout(width, height);

   return dialog;
}