My dialog fragment expands way beyond my content. I'm just showing a DatePicker and two TextViews but I get a top bar thats white, as well as a large amount of whitespace at the bottom extending to the bottom of the screen. I am using wrap_content for all related views.

enter image description here

DialogFragment's layout

<android.support.constraint.ConstraintLayout
    android:id="@+id/view_pager_dialog_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="0dp"
    android:paddingTop="0dp"
    android:paddingBottom="0dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <com.mints.util.NonSwipeableViewPager
        android:layout_marginTop="0dp"
        android:layout_marginBottom="0dp"
        android:paddingTop="0dp"
        android:paddingBottom="0dp"
        android:id="@+id/some_view_pager"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

Fragment that displays DatePicker's layout

<FrameLayout 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="wrap_content"
android:layout_height="wrap_content"
tools:context="com.mints.fragments.time.DatePickerFragment"
android:layout_gravity="center">

<android.support.constraint.ConstraintLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <DatePicker
        android:id="@+id/fragment_date_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/fragment_date_picker_next_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="32dp"
        android:text="Next"
        android:textColor="@color/colorAccent"
        android:textSize="17sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/fragment_date_picker" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="24dp"
        android:text="Cancel"
        android:textSize="17sp"
        android:textStyle="bold"
        android:textColor="@color/light_text"
        app:layout_constraintEnd_toStartOf="@+id/fragment_date_picker_next_button"
        app:layout_constraintTop_toBottomOf="@+id/fragment_date_picker" />

</android.support.constraint.ConstraintLayout>

0 Answers