I use constraint layouts. The problem is, I have a menu. when clicking on a menu point, a recycler view is displayed. I want to have a recycler view with the height of warp content. if there are too many elements in the recycler, the lower menu points are placed below and no longer visible. But the menu points should always be visible. The solution is clear, to set a maximum height to the recycler view. But: setting dp or pixels as a maximum height, that would differ between many devices. Is there an opportunity to set a maximum height to "match constraint", while the recycler view wraps the content? Or is there another solution, that the menu is not placed invisible below? Because match constraint would set the layout correctly in a constraint layout. Somethings seems to be strange: in the xml resource file, the whole layout runs correctly. When I set the recycler view to wrap content, the lower menu points are placed correctly in the layout file. But when running the application, the menu points are placed invisible. Thanks! Here the code.
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tdalayoutmiddle"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/background_white"
app:layout_constraintBottom_toTopOf="@+id/tdalayoutbottom2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tdalayoutdestroy">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tdalayoutmenu1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@color/background_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/tdarvmenu1">
<ImageView
android:id="@+id/tdalayoutheuteivdropdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/recyclerdropdown" />
<TextView
android:id="@+id/tdatextView329"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:gravity="start|center_vertical"
android:text="@string/heute"
android:textColor="@color/text_grey_hard"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tdalayoutheuteivdropdown"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/tdarvmenu1"
android:layout_width="0dp"
android:layout_height="wrap_content" //max_height="match_constraint" not working
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:background="@color/background_white"
app:layout_constraintBottom_toTopOf="@+id/tdalayoutmenu2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tdalayoutmenu1"
tools:visibility="gone" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tdalayoutmenu2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/background_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tdarvmenu1"
app:layout_constraintBottom_toTopOf="@id/tdarvmenu2">
<ImageView
android:id="@+id/tdalayoutdemnaechstivdropdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/recyclerdropdown" />
<TextView
android:id="@+id/tdatextView463"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:gravity="start|center_vertical"
android:text="@string/demnaechst"
android:textColor="@color/text_grey_hard"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tdalayoutdemnaechstivdropdown"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/tdarvmenu2"
android:layout_width="0dp"
android:layout_height="wrap_content" //max_height="match_constraint" not working
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:background="@color/background_white"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tdalayoutmenu2"
tools:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…