Android 带有recyclerview onswipe项的运动布局(alpha4)问题
我使用的是约束布局的alpha4实现“androidx.constraintlayout:constraintlayout:2.0.0-alpha4”。首先,我创建了一个单一的布局,并进行了onswipe动画,它与运动布局完美配合,然后我用recyclerview修补了布局。现在问题出现了 问题: 如果我在rv的某个特定项目中进行onswipe,那么它会变得滞后。 假设我现在正在对rv的第一个项目进行刷卡,在完全刷卡后,您会发现第13个无项目、第25个无项目已经发生了相同的刷卡,以此类推。因此,在每12项相同的刷卡后,您可以在滚动时进行检查。 我已经在中发布了整个项目,并创建了一个示例 _有关运动布局的快速要点,请参见此处Android 带有recyclerview onswipe项的运动布局(alpha4)问题,android,android-constraintlayout,android-motionlayout,Android,Android Constraintlayout,Android Motionlayout,我使用的是约束布局的alpha4实现“androidx.constraintlayout:constraintlayout:2.0.0-alpha4”。首先,我创建了一个单一的布局,并进行了onswipe动画,它与运动布局完美配合,然后我用recyclerview修补了布局。现在问题出现了 问题: 如果我在rv的某个特定项目中进行onswipe,那么它会变得滞后。 假设我现在正在对rv的第一个项目进行刷卡,在完全刷卡后,您会发现第13个无项目、第25个无项目已经发生了相同的刷卡,以此类推。因此,
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutDescription="@xml/scene_btn"
app:showPaths="true"
>
<androidx.cardview.widget.CardView
android:id="@+id/iv_recorded_program"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:cardElevation="1dp"
app:cardCornerRadius="0dp"
app:layout_constraintEnd_toStartOf="@+id/rl_recorded_program_info"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
style="@style/styleRecordedProgramImage"
android:layout_width="@dimen/guide_list_width"
android:layout_height="@dimen/guide_list_height"
android:visibility="visible"
/>
</androidx.cardview.widget.CardView>
<include
android:id="@+id/rl_recorded_program_info"
layout="@layout/text"
android:layout_width="0dp"
android:layout_height="@dimen/guide_list_height"
android:background="@color/colorPrimary"
android:visibility="visible"
app:layout_constraintEnd_toStartOf="@+id/button"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/iv_recorded_program"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="@dimen/guide_list_height"
android:background="@color/colorAccent"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.motion.widget.MotionLayout>
这是布局说明
最后,一位同事解决了这个问题@Srini感谢您的解决方案
@Override
public int getItemViewType(int position) {
return position;
}
只需要在recyclerview的适配器中重写此方法
[注意:]刷卡时仍然存在延迟。还将问题发布到
@Override
public int getItemViewType(int position) {
return position;
}