I am traiyng to write a scrolling dialog layout. As the main element I'm using ScrollView and in it there is a ConstraintLayout that contains the displayed items. The size of the ScrollView has a fixed value but I would like the width of ConstraintLayout to be match_parent and the height to be wrap_content. When I set the width to match_parent and the height is wrap_content the dialog isn't displayed in the fragment. However, if I set the width as a constant value such as the ScrollView size and set height as warp_content the dialog appears. Should I nest the layouts somehow different or what?
Here is my code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="700dp"
android:layout_height="400dp"
android:background="@color/main_blue"
android:fadeScrollbars="false"
android:fillViewport="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarFadeDuration="0"
android:scrollbarThumbVertical="@drawable/thumb_dialog"
android:scrollbarTrackVertical="@drawable/track_dialog">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="700dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/dialogTitle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="@dimen/margin_xxxxlarge"
android:layout_marginTop="@dimen/margin_xxxxlarge"
android:layout_marginEnd="@dimen/margin_xxxxlarge"
android:text="@string/dialog_title"
android:textAllCaps="true"
android:textColor="@color/main_red"
android:textSize="@dimen/text_size_xl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/dialogDescription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="@dimen/margin_xxxxlarge"
android:layout_marginTop="@dimen/margin_xxxxlarge"
android:layout_marginEnd="@dimen/margin_xxxxlarge"
android:text="@string/dialog_message"
android:textSize="@dimen/text_size_m"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dialogTitle" />
<Button
android:id="@+id/agreeButton"
style="@style/RedButton"
android:layout_width="188dp"
android:layout_height="49dp"
android:layout_marginTop="@dimen/margin_xxxxlarge"
android:layout_marginBottom="@dimen/margin_xxxxlarge"
android:background="@drawable/red_button"
android:text="@string/dialog_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/dialogTitle"
app:layout_constraintTop_toBottomOf="@+id/dialogDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Layout blueprint:
