Android : Full Screen DialogFragment

Anubhav
Geek Culture
Published in
Nov 11, 2020
Photo by Volodymyr Hryshchenko on Unsplash

Dialogs have always been an intuitive way of displaying quick details on the same screen to the user, and there are instances when we need the dialogs to occupy the full screen.
There are multiple ways to show full screen dialogs, but at times there are issues when it comes to the compatibility with all the OS Versions or at times we need to write a lot of code to achieve this.

I will show you the easiest and the fastest way to obtain this:

Add the following style in your styles.xml file :

<style name="DialogTheme" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowIsFloating">false</item>
</style>

Override the following method in the class extending the DialogFragment:

override fun getTheme(): Int {
return R.style.DialogTheme
}

That is it.

You have a full screen dialog fragment.

--

--