是否可以将ConstraintLayout放入ScrollView中? [英] Is it possible to put a ConstraintLayout inside a ScrollView?

查看:1033
本文介绍了是否可以将ConstraintLayout放入ScrollView中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以最近,在Android Studio 2.2中,有了一个新的ConstraintLayout,使设计变得更加容易,但是与RelativeLayoutLinearlayout不同,我不能使用ScrollView包围ConstraintLayot.这可能吗?如果是这样,怎么办?

So recently, with Android Studio 2.2 there's a new ConstraintLayout that makes designing a lot easier, but unlike RelativeLayout and Linearlayout, I can't use a ScrollView to surround ConstraintLayot. Is this possible? If so, how?

<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"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp">

        <android.support.constraint.ConstraintLayout
            android:id="@+id/constraintLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="0dp">

            <!-- Have whatever children you want inside -->

        </android.support.constraint.ConstraintLayout>

</ScrollView>

推荐答案

ScrollViews中的ConstraintLayout有一个错误,并且已修复. google已修复Android Studio 2.2预览版2(constraintlayout 1.0.0-alpha2)中的错误.

There was a bug with ConstraintLayout inside ScrollViews and it has been fixed. google has fixed the bug in Android Studio 2.2 Preview 2 (constraintlayout 1.0.0-alpha2).

检查此链接以获取新更新(预览2):在ScrollView和RecycleView中可以正常工作

Check this link for new update (Preview 2): works properly inside ScrollView and RecycleView

解决方案1:

解决方案是在 ScrollView

The solution was to use android:fillViewport="true" on the ScrollView

解决方案2:

使用NestedScrollView代替ScrollViewandroid:fillViewport="true"

这篇关于是否可以将ConstraintLayout放入ScrollView中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆