Android Recycler查看notifyItemRemoved动画切断

问题描述 投票:2回答:1

我目前正在为Android 6编写一个用Java编写的学校成绩经理。我刚开始使用Android,所以我不是专家。

问题: 如果我在我的RecycleView适配器上调用方法notifyItemRemoved()并且最后一个CardView从左下角移动到右上角,则会调整视图的大小并剪切动画。

现在我不知道为什么该视图被调整大小,因为RecycleView的layout_height属性是match_parent

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".SemesterActivity"
    tools:showIn="@layout/activity_semester">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/subject_list_view"
        android:padding="20dp"
        android:layout_below="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"/>

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

我把GridLayoutManager作为RecycleView的LayoutManager。

subjectListView.setLayoutManager(new GridLayoutManager(ActivityContext, 2));

我如何更新RecycleView:

SubjectAdapterObj.notifyItemRemoved(viewHolder.getAdapterPosition());

动画是默认动画。

GridLayoutManager可能是问题吗?

视频示例:

Animation cut off

抱歉。英语不是我的母语。

java android xml animation android-6.0-marshmallow
1个回答
5
投票

所以我终于找到了问题所在。 它实际上是NestedScrollView调整它的孩子的大小。 所以你需要做的就是简单地将android:fillViewport="true"添加到你的NestedScrollView

而已。我希望它可以帮助某人,虽然这不是一个非常困难的bug。我只是在错误的地方搜索过。

© www.soinside.com 2019 - 2024. All rights reserved.