我目前正在为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
可能是问题吗?
视频示例:
对不起。英语不是我的母语。
答案 0 :(得分:5)
所以我终于找到了问题所在。
实际上是NestedScrollView
调整了孩子的大小
因此,您只需将android:fillViewport="true"
添加到NestedScrollView
即可。
多数民众赞成。我希望它可以帮助某人,虽然它不是一个非常困难的bug。我只是在错误的地方搜索过。