Can NestedScrollview and ConstraintLayout work together?

I am trying to create a new one ConstraintLayout, and it is really cool and simple. I tried to apply it in the layout of the internal coordinates of NestedScrollview, where ConstraintLayoutis the parent element NestedScrollView.

But that did not work, and all the views collapsed vertically. How can i solve this?

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">

        <android.support.constraint.ConstraintLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button
                android:text="Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/button"
                android:layout_marginStart="16dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginLeft="16dp"
                android:layout_marginTop="16dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintRight_toLeftOf="@+id/button2"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp" />

            <TextView
                android:text="TextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView2"
                android:layout_marginTop="16dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                android:layout_marginBottom="16dp"
                android:layout_marginStart="16dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginLeft="16dp"
                android:layout_marginEnd="16dp"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginRight="16dp" />

            <Button
                android:text="Button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/button2"
                app:layout_constraintTop_toTopOf="@+id/textView2"
                app:layout_constraintBottom_toBottomOf="@+id/textView2"
                android:layout_marginEnd="16dp"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginRight="16dp" />

            <android.support.constraint.Guideline
                android:layout_width="411dp"
                android:layout_height="0dp"
                android:id="@+id/guideline"
                app:layout_constraintGuide_begin="367dp"
                android:orientation="horizontal"
                tools:layout_editor_absoluteY="367dp"
                tools:layout_editor_absoluteX="0dp" />

            <ProgressBar
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:id="@+id/progressBar2"
                app:layout_constraintTop_toTopOf="@+id/guideline"
                android:layout_marginStart="16dp"
                app:layout_constraintLeft_toLeftOf="parent"
                android:layout_marginLeft="16dp"
                android:layout_marginEnd="16dp"
                app:layout_constraintRight_toRightOf="parent"
                android:layout_marginRight="16dp"
                android:layout_marginTop="40dp"
                app:layout_constraintHorizontal_bias="0.25"
                android:max="100"
                android:progress="76" />
        </android.support.constraint.ConstraintLayout>
    </android.support.v4.widget.NestedScrollView>


</android.support.design.widget.CoordinatorLayout>
+4
source share

Source: https://habr.com/ru/post/1656232/


All Articles