我有一个函数,当被触发时,它成功地显示一个对话框片段,代码如下
对话片段

DialogFragment dialog;
View dialogView;
Context activityContext;

...

dialog = new DialogFragment(){
   @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
      dialogView = getActivity().getLayoutInflater().inflate(R.layout.customView, null);
      ...
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setView(dialogView);
      return builder.create();
   }
};

dialog.show(activityContext.getSupportFragmentManager() , "MyDialog");

问题是,在我用下面的代码添加了一个系统警报窗口之后,dialogfragment不再显示,但是如果我转到另一个应用程序,当我的应用程序最小化时,我可以看到dialogfragment,而它正在缩小它的大小
系统警报窗口
WindowManager mWindowManager;
WindowManager.LayoutParams params;

...

mWindowManager = (WindowManager)activityContext.getSystemService(Context.WINDOW_SERVICE);
params = new WindowManager.LayoutParams(
   WindowManager.LayoutParams.WRAP_CONTENT,
   WindowManager.LayoutParams.WRAP_CONTENT,
   WindowManager.LayoutParams.TYPE_PHONE,
   WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
   PixelFormat.TRANSLUCENT
}
params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
addView(((LayoutInflater)activityContext.getSystemService("layout_inflater")).inflate(R.layout.floatingBotton, null));

所以…为什么我看不到顶部的对话框(据我所知,对话框正在显示)
为什么只在显示系统警报窗口时发生
我尝试过使用系统警报窗口的其他标志,但我尝试过的标志也有同样的问题

最佳答案

FragmentManager fmg1=this.getChildFragmentManager();
//or
FragmentManager fmg1=this.getFragmentManager();

dialog.show(fmg1 , "MyDialog");

请试试这个也许有用

08-18 13:25