全屏DialogFragment

编程入门 行业动态 更新时间:2024-10-25 18:26:36
本文介绍了全屏DialogFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

< LinearLayout中的xmlns:机器人=htt​​p://schemas.android/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="schemas.android/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

本文发布于:2023-07-11 12:26:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094060.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:全屏   DialogFragment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!