问题描述
以下来自我的布局 xml 的片段:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/fragment_home_info_card_car_position"
android:maxHeight="300dp"
>
<androidx.core.widget.nestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp">
<include
android:id="@+id/fragment_home_filter_chips"
layout="@layout/selection_chips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp" />
</androidx.core.widget.nestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
正确包裹内容,包裹 include
且不超过高度。但是滚动时 include
的内容会被截断大约 100dp。这可能是因为包含的填充速度相当慢(在后台使用 lifeCyclescope
协程)。
为了克服这个问题,我只是将高度限制为一个固定值,如下所示:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="300dp"
app:layout_constraintTop_toBottomOf="@id/fragment_home_info_card_car_position"
>
...
现在突然正确地调整了包含的高度,我可以向下滚动它的底部,但是如果它小于 300dp,当然不受内容的限制...
我的问题是,如何像第一个片段中那样限制高度,并确保我的包含完全展开(在滚动视图中展开查看)?
maxHeight
是否做了一些在这里不太好的“魔法”?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)