【发布时间】:2020-04-06 12:34:22
【问题描述】:
我希望能够滚动浏览 LinearLayout,其中每个元素都是适合整个屏幕的 ConstraintLayout。
我在每个布局中为 layout_height 尝试了多个值,但似乎没有任何效果。 我可以在适合我的屏幕的 layout_height 中硬编码,但这并不理想。
这是我目前拥有的:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
这是产生的设计:
虽然设计看起来符合我的要求,但我无法向下滚动查看后续的 ConstraintLayout。
非常感谢任何帮助。我已经在网上搜索并尝试修复此问题数小时但没有结果
【问题讨论】:
-
请显示你想要的输出,也看看这里,How to ask a good question
-
这个不行,ConstraintLayout需要wrap_content和包含子布局或者设置固定Height
-
感谢您向我发送该链接,我现在将添加更多详细信息
标签: android android-linearlayout android-constraintlayout android-scrollview