RecyclerView 添加动画
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/bounce_interpolator" > <scale android:duration="500" android:fromXScale="0.1" android:fromYScale="0.1" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0" /> <alpha android:duration="500" android:fromAlpha="0" android:toAlpha="1.0" /> </set>
开始RecyclerView 设置动画
private void iniList(){ list = new ArrayList<>(); for (int i = 0 ; i < 30 ; i ++){ list.add(i + " -- tween 测试 --"); } } private void iniRecyclerView(){ recyclerView = findViewById(R.id.recycler); GridLayoutManager manager = new GridLayoutManager(this,1); recyclerView.setLayoutManager(manager); //设置动画 LayoutAnimationController lac=new LayoutAnimationController(AnimationUtils .loadAnimation(this, R.anim.in_anim)); lac.setDelay(0.5f); lac.setOrder(LayoutAnimationController.ORDER_RANDOM); recyclerView.setLayoutAnimation(lac); TweenRecyclerAdapter adapter = new TweenRecyclerAdapter(list); recyclerView.setAdapter(adapter); }