如何在另一个布局中使用 ScrollView?
How to use ScrollView inside another layout?
我想在另一个约束布局中使用 ScrollView。但是当我放置它时,ScrollView 内的所有视图都消失了。为什么,以及如何解决它?
非常感谢您的帮助,希望您度过愉快的一天!
我的xml
<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"
tools:context=".home.profile.PreViewProfileFragment">
<androidx.constraintlayout.widget.Guideline
... />
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/vertical_2"
app:layout_constraintEnd_toEndOf="@id/vertical_98"
app:layout_constraintTop_toTopOf="@id/horizontal_10"
app:layout_constraintBottom_toBottomOf="@id/horizontal_98">
<Another constraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
这样的蓝图
像下面这样使用:
<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"
tools:context=".home.profile.PreViewProfileFragment">
<androidx.constraintlayout.widget.Guideline
... />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintStart_toEndOf="@id/vertical_2"
app:layout_constraintEnd_toEndOf="@id/vertical_98"
app:layout_constraintTop_toTopOf="@id/horizontal_10"
app:layout_constraintBottom_toBottomOf="@id/horizontal_98">
<Another constraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
我想在另一个约束布局中使用 ScrollView。但是当我放置它时,ScrollView 内的所有视图都消失了。为什么,以及如何解决它?
非常感谢您的帮助,希望您度过愉快的一天!
我的xml
<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"
tools:context=".home.profile.PreViewProfileFragment">
<androidx.constraintlayout.widget.Guideline
... />
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toEndOf="@id/vertical_2"
app:layout_constraintEnd_toEndOf="@id/vertical_98"
app:layout_constraintTop_toTopOf="@id/horizontal_10"
app:layout_constraintBottom_toBottomOf="@id/horizontal_98">
<Another constraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
这样的蓝图
像下面这样使用:
<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"
tools:context=".home.profile.PreViewProfileFragment">
<androidx.constraintlayout.widget.Guideline
... />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintStart_toEndOf="@id/vertical_2"
app:layout_constraintEnd_toEndOf="@id/vertical_98"
app:layout_constraintTop_toTopOf="@id/horizontal_10"
app:layout_constraintBottom_toBottomOf="@id/horizontal_98">
<Another constraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>