相关疑难解决方法(0)

是否可以将ConstraintLayout放入ScrollView中?

所以最近,与Android Studio 2.2中有一个新的ConstraintLayout,使设计轻松了很多,但不像RelativeLayout并且Linearlayout,我不能使用ScrollView包围ConstraintLayot.这可能吗?如果是这样,怎么样?

<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>
Run Code Online (Sandbox Code Playgroud)

user-interface android android-layout android-constraintlayout

80
推荐指数
8
解决办法
8万
查看次数

是否可以在Blueprint模式下使用ConstraintLayout滚动ScrollView?

所以我一直在ScrollView中使用ConstraintLayout开发这个布局.它工作正常,但现在我遇到了问题.我必须在屏幕外扩展布局.我可以在设计模式下滚动,但如果没有它被卡在顶部,我就无法添加任何内容.约束是针对早期的对象,而不是我正在添加的当前对象.

我可以在Blueprint模式下添加约束,但看起来我无法在蓝图模式下滚动ScrollView.这甚至可能吗?使用Android Studio 2.2(发布)和constraint-layout:1.0.0-alpha8

我尝试在设计模式下这样做,但它不滚动.有任何想法吗?

使用ConstraintLayout正常滚动会导致约束停留在同一位置.

编辑:

已更新alpha9但仍未解决

编辑2:

beta1也不起作用.AS 2.2.2.

编辑3:

样本布局:

<Button
    android:text="Button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/sampleButton"
 />

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="HardcodedText">

    <android.support.constraint.ConstraintLayout

        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!-- ETC constraints -->
    </android.support.constraint.ConstraintLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-scrollview android-studio-2.2 android-constraintlayout

12
推荐指数
1
解决办法
7301
查看次数

如何垂直滚动ConstraintLayout?

主要活动的内容如下:

主屏幕看起来像(所有这些在ConstraintLayout内):

  • 图像标题
  • 日期
  • 图像本身
  • 图片描述

图像描述可能太长而无法显示,为了解决这个问题,我可以把它放在ScrollView中,这样就可以了.但是,我想ScrollView整个ConstraintLayout,这不能正常工作:无法滚动,一些TextViews不会出现!

我是Android开发的新手; 帮助将不胜感激!


相关守则:

<android.support.constraint.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:id="@+id/desciptionScroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.picture.nasa.nasadailyimage.NasaDailyImage"
    tools:showIn="@layout/activity_nasa_daily_image">

 <TextView
    android:id="@+id/imageTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="8dp"
    android:layout_marginStart="8dp"
    android:text="@string/test_image_title"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

 <TextView
    android:id="@+id/imageDate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="8dp"
    android:layout_marginStart="8dp"
    android:text="@string/test_image_date"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/imageTitle" />

 <ImageView
    android:id="@+id/imageDisplay"
    android:layout_width="368dp"
    android:layout_height="408dp"
    android:layout_marginLeft="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="3dp"
    android:src="@mipmap/test_image"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/imageDate" />

<TextView 
    android:id="@+id/imageDescription"
    android:layout_width="368dp"
    android:layout_height="0dp"
    android:layout_marginLeft="8dp" 
    android:layout_marginStart="8dp" 
    android:layout_marginTop="4dp" 
    android:text="@string/test_image_description" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/imageDisplay" />

</android.support.constraint.ConstraintLayout>    
Run Code Online (Sandbox Code Playgroud)

android android-scrollview android-constraintlayout

7
推荐指数
1
解决办法
2万
查看次数