android - recyclerview水平项目上的下降动画
解决方案
来自一个项目:请在数据集更改后调用recyclerView.scheduleLayoutAnimation(),否则动画将不起作用。
活动布局.xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation"
android:orientation="vertical">
</ScrollView>
activity_recycler_view.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@color/colorWhite"
tools:context=".activities.AttendanceActivity">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
item_animation_fall_down.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500">
<translate
android:fromYDelta="-20%"
android:toYDelta="0"
android:interpolator="@android:anim/decelerate_interpolator"
/>
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:interpolator="@android:anim/decelerate_interpolator"
/>
<scale
android:fromXScale="105%"
android:fromYScale="105%"
android:toXScale="100%"
android:toYScale="100%"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@android:anim/decelerate_interpolator"
/>
</set>
布局动画.xml
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/item_animation_fall_down"
android:animationOrder="normal"
android:delay="15%" />
推荐阅读
- javascript - 我的组件在第一次渲染中无法读取属性,但在第二次渲染中我的属性已经有了
- swift - 对齐 UISwitch 以对齐到中心
- java - Java初学者手动输入值并打印对象void main的详细信息
- javascript - 达到最小值或最大值时停止拖动事件
- amazon-web-services - AWS VPC 中的安全数据库
- c++ - 为什么 std::thread::join 在这里出现段错误?
- c# - 我如何在不同类的异步方法中执行 ping 和接收 ms?
- python - 将 Iris 数据集目标名称应用于混淆矩阵
- java - 是否可以将 ORM 与 Vert.x 一起使用?
- javascript - RegExp 中的无效正则表达式错误