Android ScrollView内部ConstraintLayout未按预期工作
ScrollView布局似乎不像其正常行为那样工作。 任何面对/尝试过这种xml设计结构的人,请给出建议 这是xml文件Android ScrollView内部ConstraintLayout未按预期工作,android,scrollview,android-constraintlayout,Android,Scrollview,Android Constraintlayout,ScrollView布局似乎不像其正常行为那样工作。 任何面对/尝试过这种xml设计结构的人,请给出建议 这是xml文件 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http:/
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">
<ScrollView
android:id="@+id/scrollview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".fragment.HomeFragment">
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scrollview">
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
修改您的
标记以匹配以下内容:
如果不指定底部约束(并对高度使用
wrap_content
),则ScrollView
将调整自身大小,使其足以容纳所有内容,但会被父级ConstraintLayout
剪裁。如果所有内容都适合,就没有什么可以滚动了(即使你看不到所有内容,因为家长正在剪辑它)。你能告诉我实际的问题吗?我检查了一下,它工作正常,没有在ConstraintLayout内容中滚动。@RajuTukadiya你能解释一下你的用例吗,比如你想实现什么?
<ScrollView
android:id="@+id/scrollview"
android:layout_width="0dp"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/cardview">
<androidx.cardview.widget.CardView
android:id="@+id/cardview"