gpt4 book ai didi

android - 如何在 recyclerview 中使用运动布局

转载 作者:行者123 更新时间:2023-12-04 12:41:29 26 4
gpt4 key购买 nike

尝试使用 MotionLayoutRecyclerView ,

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

android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff



fragment 布局代码是
<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>

和 layoutDescription 代码是:
<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>

最佳答案

app:moveWhenScrollAtTop="@+id/rv_list"

app:moveWhenScrollAtTop 的值应该是 bool 值。

关于android - 如何在 recyclerview 中使用运动布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55097187/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com