Why doesn't Linear Layout maxHeight work? maxHeight does not work on RecyclerView
Height of section2 becomes 0 as I followed the instructions from above post.
My View Requirement is to have a:
- TopBar followed by
- 3 sections
- Section1 wraps height followed by
- Section2 maxHeight to 200dp or take/fill available height (followed by Section3)
- Section3 height 45dp and aligns to bottom and
- All 3 sections must be visible.
- This entire view should center_parent of rootView of the activity.
- Section1 is correct
- Section3 is correct
- But section2 height becomes 0 and is not visible if I don't set the min constraint.
- If I set minHeight constraint for section2, section3 becomes invisible.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_home_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/purple"
tools:context="mose.moseinc.com.Tymeit.Activities.Home.Activity">
<RelativeLayout
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:background="@color/aqua_blue"
android:layout_height="wrap_content">
<mose.moseinc.com.Tymeit.Views.Home.TopBar
android:id="@+id/top_bar_home_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</mose.moseinc.com.Tymeit.Views.Home.TopBar>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/mainView"
android:layout_below="@+id/top_bar"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<CustomView1
android:id="@+id/section1"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="0dp"
android:background="@color/green_theme"
app:tileHeight="40dp"
android:layout_height="wrap_content" />
<CustomView2
android:id="@+id/section2"
app:layout_constraintTop_toBottomOf="@+id/section1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintHeight_max="200dp"
android:layout_height="0dp">
</CustomView2>
<CustomView3
android:id="@+id/bottomBar"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:layout_height="45dp">
</CustomView3>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</RelativeLayout>