I've created a drawer using a DrawerLayout which contains a RecyclerView with the items. I've also attached a layoutAnimation to the RecyclerView to have the items come in from the side when opening the drawer. This works peachy the first time but when opening the drawer the second time everything is already in place. I would like the layoutAnimation to run every time the drawer is opened.
What I've tried so far is to have a custom ActionBarDrawerToggle (I need that one anyway), and add the following:
@Override
public void onDrawerOpened(final View drawerView) {
super.onDrawerOpened(drawerView);
final RecyclerView recyclerView =
(RecyclerView) drawerView.findViewById(R.id.drawer_content);
if (recyclerView != null) {
recyclerView.startLayoutAnimation();
}
}
It works sort of, because it re-runs the animation, however all the items are there when opening the drawer, then they disappear and then the animations starts.
Anyone have a solution how to "reset" the drawer item views every time the drawer is closed?
Not sure these are needed but I'll include them anyway
<--! layout_animation.xml -->
<layoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/slide_from_right"
android:delay="15%"
android:animationOrder="normal"
/>
<--! slide_from_right.xml -->
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0"
/>