DialogFragment全屏显示填充两侧全屏、DialogFragment

2023-09-04 08:31:02 作者:心疼妳的心疼

我创建所显示的动作条下的自定义DialogFragment。到目前为止,一切都很正常。布局参数对话框片段是 match_parent 的宽度和 WRAP_CONTENT 的高度。

I am creating a custom DialogFragment that is displayed underneath the actionbar. So far everything works great. The layout parameters for dialog fragment are match_parent for width and wrap_content for height.

我曾尝试包括设置布局参数.WIDTH并通过获取显示器尺寸和删除主题每一个解决方案。然而无论是有少量的左,右和顶侧是看不见的对话框的空间。我需要知道如何删除这个空间,所以它实际上符合屏幕的宽度,并希望摆脱顶边距为好。

I have tried every solution including setting the layout parameters .width and by getting Display size and removing the themes. However no matter what there is a small amount of space on left, right and top side of the dialog that is invisible. I need to know how to remove this space so it actually matches the width of the screen and hopefully gets rid of the top padding as well.

推荐答案

我使用自定义对话框主题想通了。 windowIsFloating真正将摆脱背景,但会增加一些额外的空间背景作为背景之下。在这种情况下,你可以使用windowBackground @null将其删除。

I figured it out using custom dialog theme. windowIsFloating true will get rid of the background but will add some extra space underneath the background as a background. In which case you can use windowBackground @null to erase it.

<style name="CustomDialog" parent="@android:style/Theme.Holo.Light" >
    <item name="android:windowBackground">@null</item>
    <item name="android:windowIsFloating">true</item>
</style

感谢您Raghunandan谁给我,包括所有样式属性的链接。我花了一段时间,但我经历了这个文件,发现非常有趣的元素。肯定有一起来看看下面的链接发布到探索的主题风格。

Thank you to Raghunandan who gave me the link that includes all style attributes. It took me a while but I went through that file and found very interesting elements. Definitely have a look at the link posted below to explore theme styles.

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml