android - 为什么我的 NestedScrollView 不将自身定位在我的 ConstraintView 下方,尽管我使用了约束?
问题描述
谁能帮我?
我想在 ConstraintLayout 下面放置一个 NestedScrollView。这两个布局都在相同的层次结构级别,在外部 ConstraintLayout 内。
层次结构如下:
ConstraintLayout(1) 包含 ConstraintLayout(1.1) 和 NestedScrollView。
NestedScrollView 包含 ConstraintLayout(1.2)。
ConstraintLayout(1.2) 包含 ConstraintLayout(1.2.1) 和 ConstraintLayout(1.2.2)。
我的目标是将 NestedScrollView(包括里面的所有内容)放在 ConstraintLayout(1.1) 下方。
我试图使用约束来对齐它。但是,它不能按预期工作,我不清楚为什么 NestedScrollView 没有在内部 ConstraintLayout 下方对齐。
布局相关代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- +++++ OPENING BRACKET OF ConstraintLayout 1 +++++-->
<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"
android:background="@color/colorwh">
<!-- +++++ OPENING BRACKET OF ConstraintLayout 1.1 +++++-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/paymentDescriptor"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- +++++ CLOSING BRACKET OF ConstraintLayout 1.1 +++++-->
<androidx.core.widget.NestedScrollView
android:id="@+id/paymentRollover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/paymentDescriptor"
android:fillViewport="true">
<!-- +++++ OPENING BRACKET OF ConstraintLayout 1.2 +++++-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/availablePayments"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<!-- +++++ OPENING BRACKET OF ConstraintLayout 1.2.1 +++++-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buy_all"
android:layout_width="match_parent"
android:layout_height="@dimen/paymentMenuHeight"
android:layout_marginStart="@dimen/paymentMarginLeft"
android:layout_marginLeft="@dimen/paymentMarginLeft"
android:layout_marginEnd="@dimen/paymentMarginRight"
android:layout_marginRight="@dimen/paymentMarginRight"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/paymentMarginTop">
<ImageView
android:id="@+id/flag_all"
android:layout_width="@dimen/paymentFLAG_width"
android:layout_height="@dimen/paymentFLAG_height"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/paymentTV_marginsVertical"
android:layout_marginLeft="@dimen/paymentTV_marginLeft"
android:layout_marginStart="@dimen/paymentTV_marginLeft"
android:layout_marginBottom="@dimen/paymentTV_marginsVertical">
</ImageView>
<TextView
android:id="@+id/language_all"
android:layout_width="@dimen/paymentTV_width"
android:layout_height="@dimen/paymentTV_height"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/flag_all"
android:layout_marginLeft="@dimen/paymentTV_marginLeft"
android:layout_marginStart="@dimen/paymentTV_marginLeft"
android:text="@string/language_all"
android:textSize="@dimen/paymentTV_textSize"
android:gravity="center"
android:textAllCaps="true"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/descriptionBlock_all"
android:layout_width="@dimen/paymentDescription_width"
android:layout_height="@dimen/paymentDescription_height"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/flag_all"
android:layout_marginTop="@dimen/paymentDescription_marginVertical"
android:layout_marginLeft="@dimen/paymentTV_marginLeft"
android:layout_marginStart="@dimen/paymentTV_marginLeft"
android:text="@string/descriptionBlock_all"
android:textSize="@dimen/paymentDescription_textSize"
android:gravity="center"
android:textStyle="italic">
</TextView>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- +++++ CLOSING BRACKET OF ConstraintLayout 1.2.1 +++++-->
<!-- +++++ OPENING BRACKET OF ConstraintLayout 1.2.2 +++++-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/buy_de"
android:layout_width="match_parent"
android:layout_height="@dimen/paymentMenuHeight"
android:layout_marginStart="@dimen/paymentMarginLeft"
android:layout_marginLeft="@dimen/paymentMarginLeft"
android:layout_marginEnd="@dimen/paymentMarginRight"
android:layout_marginRight="@dimen/paymentMarginRight"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/buy_all"
android:layout_marginTop="@dimen/paymentMarginTop">
<ImageView
android:id="@+id/flag_de"
android:layout_width="@dimen/paymentFLAG_width"
android:layout_height="@dimen/paymentFLAG_height"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/paymentTV_marginsVertical"
android:layout_marginLeft="@dimen/paymentTV_marginLeft"
android:layout_marginStart="@dimen/paymentTV_marginLeft"
android:background="@drawable/flag_col_1">
</ImageView>
<TextView
android:id="@+id/language_de"
android:layout_width="@dimen/paymentTV_width"
android:layout_height="@dimen/paymentTV_height"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/flag_de"
android:layout_marginLeft="@dimen/paymentTV_marginLeft"
android:layout_marginStart="@dimen/paymentTV_marginLeft"
android:text="@string/language_de"
android:textSize="@dimen/paymentTV_textSize"
android:gravity="center"
android:textAllCaps="true"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/descriptionBlock_de"
android:layout_width="@dimen/paymentDescription_width"
android:layout_height="@dimen/paymentDescription_height"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/flag_de"
android:layout_marginTop="@dimen/paymentDescription_marginVertical"
android:layout_marginLeft="@dimen/paymentTV_marginLeft"
android:layout_marginStart="@dimen/paymentTV_marginLeft"
android:text="@string/descriptionBlock_de"
android:textSize="@dimen/paymentDescription_textSize"
android:gravity="center"
android:textStyle="italic">
</TextView>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- +++++ CLOSING BRACKET OF ConstraintLayout 1.2.2 +++++-->
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- +++++ CLOSING BRACKET OF ConstraintLayout 1.2 +++++-->
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- +++++ CLOSING BRACKET OF ConstraintLayout 1 +++++-->
解决方案
推荐阅读
- django-forms - 在 Django Signals 中使用额外的表单字段
- tensorflow - 如何在 keras 网络中手动设置参数,比 model.set_weight() 更有效?
- python - 当单击带有 pysimpleGUI 的按钮并在多行中显示输出时,如何解决卡住的问题?
- android - 如何在 Kotlin 中将 List 转换为 ArrayList
- javascript - 达到容量时,IndexedDB 拒绝删除存储
- nginx - NGINX Slug 目录重写
- java - 如何将字节转换为更有用的数据?
- javascript - 如何通过 React 中的预签名 S3 URL 预览图像?
- dictionary - Kotlin 地图类型推断失败
- wordpress - Wordpress CMS 上的一个站点多个主题