window – windowIsFloating attribute in Android theme-ThrowExceptions

Exception or error:

What does this attribute really do?

I’ve read the documentation and I understand what it’s supposed to be. However, when I use it in a theme (I created a style with the android:Theme.Dialog as the parent), changing the value for this attribute doesn’t seem to have any effect.

How to solve:

I don’t know all of the effects of setting windowIsFloating to true, but one thing that I noticed is that when it is set to true, the activity would not expand the width to fill the screen, even if you set the layout width to match_parent (i.e. android:layout_width="match_parent")


From my experiments, it seems to affect how the window reacts to the soft input. It you set this to false, the window won’t slide up when the keyboard becomes visible.


When you use Dialog Theme, this attribute default is true.

<style name="Base.V7.Theme.AppCompat.Light.Dialog" parent="Base.Theme.AppCompat.Light">
        <item name="android:windowIsFloating">true</item>

And in this case, the Dialog will create PhoneWindow with this code:

    if (mIsFloating) {
        setLayout(WRAP_CONTENT, WRAP_CONTENT);
        setFlags(0, flagsToUpdate);

It will cause contentView always wrap content as small as. You could set it to false or Manual update the Dialog window layout to MATCH_PARENT like this:

override fun onStart() {
    dialog?.window?.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)

Leave a Reply

Your email address will not be published. Required fields are marked *