[英]height is incorrect even with layout_constraintHeight_max/min set to 200dp
Why doesn't Linear Layout maxHeight work? 为什么线性布局 maxHeight 不起作用? maxHeight does not work on RecyclerView
maxHeight 不适用于 RecyclerView
Height of section2 becomes 0 as I followed the instructions from above post.按照上面帖子的说明,section2 的高度变为 0。
My View Requirement is to have a:我的观点要求是:
<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>
android:layout_height="0dp"
and app:layout_constraintHeight_max="200dp"
dont work together. android:layout_height="0dp"
和app:layout_constraintHeight_max="200dp"
一起使用。 Layout_height will always take prio and set the height of CustomView2 to 0. Layout_height 将始终采用优先级并将 CustomView2 的高度设置为 0。
What you need is to set android:layout_height="parent"
.您需要设置
android:layout_height="parent"
。 Then it will try to take all available space it can get on the screen, but not exceed 200dp.然后它会尝试占用屏幕上所有可用空间,但不会超过 200dp。
You set CustomView3 to visibility="gone"
this does not match your requirement of visibility.您将 CustomView3 设置为
visibility="gone"
这不符合您的可见性要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.