private void initAinm() { //經過加載XML動畫設置文件來建立一個Animation對象; Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.left); //獲得一個LayoutAnimationController對象; LayoutAnimationController lac = new LayoutAnimationController(animation); //設置控件顯示的順序; lac.setOrder(LayoutAnimationController.ORDER_NORMAL); //設置控件顯示間隔時間; lac.setDelay(0.2f); //爲ListView設置LayoutAnimationController屬性; mRecyclerView.setLayoutAnimation(lac); }
**android
**ide
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="500" android:fromXDelta="100%" android:fromYDelta="0" android:toXDelta="0" android:toYDelta="0" /> <alpha android:duration="500" android:fromAlpha="0" android:toAlpha="1" /> </set>
public void showResult(List<MessageBean> messages) { initAinm(); if(messages!=null&&messages.size()>0){ if(adapter == null){ adapter = new MessageAdapter(messages,getContext()); getActivity().runOnUiThread(new Runnable() { @Override public void run() { mRecyclerView.setAdapter(adapter); } }); }else { getActivity().runOnUiThread(new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); } } }
須要其餘效果。可自定義left文件,換成其餘的效果動畫