I have an AlertDialog with a ConstraintLayout as a view and all of the children have a height of 0dp
, i.e match constraints:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxHeight="400dp">
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<!-- Other children -->
I want the dialog to take as much height as possible on screen, to a maximum of 400dp
. However the layout above produces a dialog with 0 height, invisible.
I tried using dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
. The dialog took the whole screen height but the ConstraintLayout was still invisible.
Is there any way to do this?