我想制作一个布局,让我使用约束布局向下滚动,但我不知道该怎么做。 --- 应该是 ScrollView
的父 ConstraintLayout
吗?
<?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">
<android.support.constraint.ConstraintLayout
android:id="@+id/Constraint"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
还是反过来?也许有人可以为我指出一个很好的教程或举个例子,我似乎找不到。
另外,我不知道这是一个错误还是我没有设置的一些配置,但我见过这样的图像:
在蓝图“蓝色矩形”之外有一些组件但它们是可见的,而在我这边,如果我将组件放在“空白”上,我看不到它或将它移动到任何地方,它出现在组件树上.
更新 :
我在设计工具中找到了一种使约束布局可滚动的方法,使用水平引导线将约束布局边框下推并将其延伸到设备之外,之后,您可以使用引导线作为约束布局的新底部来锚定组件。
原文由 gtovar 发布,翻译遵循 CC BY-SA 4.0 许可协议
这里有很多答案,没有什么很简单的。 It’s important that the ScrollView’s
layout_height
is set tomatch_parent
while thelayout_height
of the ContraintLayout iswrap_content