本文介绍了全屏DialogFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建MATCH_PARENT宽度的DialogFragment所以对话框几乎全屏幕(离开填充周围的边缘为流动的样子)。我已经看到了这个解决方案全屏DialogFragment在Android的但我试图避免的黑客设定宽度1000dp。由于我目前的布局,无论我用FILL_PARENT或MATCH_PARENT它似乎是设置宽度和高度WRAP_CONTENT。

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>
 

我已经使用这个解决方案的对话框(未DialogFragment),它按预期工作:

  getWindow()setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)。
 

解决方案

尝试切换到RelativeLayout的,而不是LinearLayout中。它的工作在我的情况

I am trying to create a DialogFragment with a width of MATCH_PARENT so the dialog is nearly full screen (leaving the padding around the edges for the floating look). I have seen this solution Full Screen DialogFragment in Android but am trying to avoid the hack of setting the width to 1000dp. With my current layout, whether I use FILL_PARENT or MATCH_PARENT it seems to be setting the width and height to WRAP_CONTENT.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

I have used this solution for Dialog (not DialogFragment) and it works as expected:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
解决方案

try to switch to RelativeLayout instead of LinearLayout. It worked in my case

这篇关于全屏DialogFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 22:52