如何在使用MotionLayout时遇到障碍

时间:2018-11-07 15:26:34

标签: android android-motionlayout

因此,我一直在尝试使用MotionLayout来使某些动画起作用,但是在将ConstraintLayout转换为MotionLayout时遇到了障碍的问题。我有一个屏障,该屏障引用父布局顶部的两个标题视图,以及一个ViewGroup,该约束将ViewGroup的顶部限制在屏障的底部;但是,当我将ConstraintLayout转换为新的MotionLayout时,屏障不再起作用。我的ViewGroup被约束在父对象的顶部,而不是障碍的底部。我认为这是因为该库仍处于Alpha状态,但我希望有人对此有某种解决方法。

编辑:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout 
    usual stuff here
    app:layoutDescription="@xml/scene">

    <CustomHeaderView
        android:id="@+id/first_header"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:attachedRecyclerView="@+id/some_recycler_view"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <SecondCustomHeaderView
        android:id="@+id/second_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="visible"
        app:attachedRecyclerView="@+id/some_recycler_view"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <android.support.constraint.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="first_header,second_header"
        tools:layout_editor_absoluteY="241dp" />

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/some_swipe_container"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="@id/barrier"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nested_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/some_recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="blocksDescendants"
                android:nestedScrollingEnabled="false" />

        </android.support.v4.widget.NestedScrollView>

    </android.support.v4.widget.SwipeRefreshLayout>


</android.support.constraint.motion.MotionLayout>

谢谢!

0 个答案:

没有答案