MrAndre
MrAndre

Reputation: 1017

My dialog is now filling the full height instead of wrapping around the content

I am trying to use a dialog window where people can fill in some info. But I got the problem that it fills in my whole screen in height (not width). Dialog

And here is my layout file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/dialog_bg"
    tools:context=".UI.Main.Create.CreateStoryDialogFragment">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        //some fields

    </LinearLayout>
</RelativeLayout>

And I use this line in my DialogFragment:

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

Could someone maybe say where I am going wrong?

Upvotes: 0

Views: 47

Answers (1)

Aaron
Aaron

Reputation: 3894

Use android:layout_height="wrap_content" if you want to wrap the view by its content, it should work if you replace all of android:layout_height="match_parent" in your layout XML.

And you might need to replace the RelativeLayout with a FrameLayout.

Upvotes: 1

Related Questions