MotionLayout с вертикальным ScrollView - PullRequest
1 голос
/ 05 апреля 2019

Я пытаюсь сделать анимацию с помощью макета движения и хочу установить scrollView в качестве targetAnchor для сцены движения при переходе по Wi-Fi, но это не работает.Может быть, я ничего не знаю о переходе onSwipe.

Вот мой файл макета

    <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/main_background_color"
        app:layoutDescription="@xml/base_scroll_scene">

        <ImageView
            android:id="@+id/background_image"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="@dimen/scrollable_background_image_margin_bottom"
            android:scaleType="centerCrop"
            android:src="@drawable/lift_bg"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/top_gradient_mask_height"
            android:background="@drawable/top_gradient_mask"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/ski_more_logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/ski_more_logo_margin_top"
            android:src="@drawable/ic_skimore_logo"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/locked_icon"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_marginTop="@dimen/locked_icon_margin_top"
            android:src="@drawable/ic_lock"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/ski_more_logo" />

        <FrameLayout
            android:id="@+id/bottom_gradient_mask"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@drawable/bottom_gradient_mask"
            app:layout_constraintBottom_toBottomOf="@+id/background_image" />

        <ScrollView
            android:id="@+id/content_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:overScrollMode="never"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent">


            <FrameLayout
                android:id="@+id/content_container_view"
                android:layout_width="match_parent"
                android:clickable="false"
                android:layout_height="match_parent" />


        </ScrollView>
    </androidx.constraintlayout.motion.widget.MotionLayout>

В режиме прокрутки программно добавляю контент с большой высотой, который можно прокручивать.

А вот и моя сцена движения

<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:motion="http://schemas.android.com/apk/res-auto">
    <Transition
        motion:constraintSetEnd="@+id/end"
        motion:constraintSetStart="@+id/start"
        motion:duration="1000">
        <OnSwipe
            motion:dragDirection="dragUp"
            motion:touchAnchorId="@+id/content_scroll_view"
            motion:touchAnchorSide="top" />
    </Transition>

    <ConstraintSet android:id="@+id/start"/>
    <ConstraintSet android:id="@+id/end">
        <Constraint
            android:id="@+id/background_image"
            android:layout_width="0dp"
            android:layout_height="@dimen/top_gradient_mask_height"
            android:layout_marginBottom="@dimen/scrollable_background_image_margin_bottom"
            android:scaleType="centerCrop"
            android:src="@drawable/lift_bg"
            motion:layout_constraintEnd_toEndOf="parent"
            motion:layout_constraintStart_toStartOf="parent"
            motion:layout_constraintTop_toTopOf="parent" />

    </ConstraintSet>

</MotionScene>

Пожалуйста, помогите мне, спасибо.

1 Ответ

0 голосов
/ 15 мая 2019

Вы пытались заменить ScrollView на NestedScrollView?

И, кроме того, я бы также определил ConstraintSet «начало».

...