Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在recyclerview中使用运动布局_Android_Android Recyclerview_Scroll_Swipe_Android Motionlayout - Fatal编程技术网

Android 如何在recyclerview中使用运动布局

Android 如何在recyclerview中使用运动布局,android,android-recyclerview,scroll,swipe,android-motionlayout,Android,Android Recyclerview,Scroll,Swipe,Android Motionlayout,尝试将MotionLayout与RecyclerView一起使用 向上滚动时,应用程序因错误而崩溃: android.content.res.Resources$NotFoundException:无法找到 资源ID#0xffffffff 片段布局代码为 <android.support.constraint.motion.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln

尝试将
MotionLayout
RecyclerView
一起使用

向上滚动时,应用程序因错误而崩溃:

android.content.res.Resources$NotFoundException:无法找到 资源ID#0xffffffff

片段布局代码为

<android.support.constraint.motion.MotionLayout
    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"
    app:layoutDescription="@xml/collapsing_config_order_details"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    ...

<android.support.v7.widget.CardView
        android:id="@+id/cardView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        app:layout_constraintEnd_toEndOf="@+id/tv_delivery_type"
        app:layout_constraintStart_toStartOf="@+id/imageView15"
        app:layout_constraintTop_toBottomOf="@+id/view4">

     ...

</android.support.v7.widget.CardView>

<android.support.v7.widget.RecyclerView
        android:id="@+id/rv_list"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/cardView"
        app:layout_constraintStart_toStartOf="@+id/cardView"
        app:layout_constraintTop_toBottomOf="@+id/cardView" />

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

...
...
布局描述代码为:

<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Transition
        app:constraintSetEnd="@id/collapsed"
        app:constraintSetStart="@id/expanded">

        <OnSwipe
            app:dragDirection="dragUp"
            app:touchAnchorSide="top"
            app:moveWhenScrollAtTop="@+id/rv_list" />

    </Transition>

    <ConstraintSet android:id="@+id/expanded"
            android:id="@+id/cardView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="@+id/tv_delivery_type"
            app:layout_constraintStart_toStartOf="@+id/imageView15"
            app:layout_constraintTop_toBottomOf="@+id/view4" />
    </ConstraintSet>

    <ConstraintSet android:id="@+id/collapsed">
    <Constraint
            android:id="@+id/cardView"
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="@+id/tv_delivery_type"
            app:layout_constraintStart_toStartOf="@+id/imageView15"
            app:layout_constraintTop_toBottomOf="@+id/view4" />
    </ConstraintSet>

</MotionScene>

更改

<ConstraintSet android:id="@+id/expanded"
            android:id="@+id/cardView"

每个
约束集
本身都应该有
约束
,并且您需要指定想要更改场景的尽可能多的
约束
,就像如果您想要在一次交互中同时移动A和B,您需要在一个
约束集

另外,我不确定您想要实现什么,但我认为您需要编写如下代码

<OnSwipe
        app:dragDirection="dragUp"
        app:touchAnchorId="@id/rv_list"
        app:touchAnchorSide="top" />

这意味着您正在瞄准
rv_list
以触发该操作

app:moveWhenScrollAtTop="@+id/rv_list"

app:movewhenScrollatop的值应为布尔值。

android:nestedScrollingEnabled=“false”
添加到您的
recyclerView


对我有效。

在您的自动生成资源文件中是否有id为0xffffffff的资源?不,该id在R.java中也没有预设,因为您已经在
布局
文件中添加了
viewId
,您需要将
android:id=“@+id/cardwiew”
更改为
android:id=“@id/cardwiew”
也适用于我,tks
app:moveWhenScrollAtTop="@+id/rv_list"