Skip to content

Instantly share code, notes, and snippets.

View patrick-elmquist's full-sized avatar

Patrick Elmquist patrick-elmquist

View GitHub Profile
@patrick-elmquist
patrick-elmquist / layout_animation_fall_down.xml
Last active July 26, 2017 18:05
Enter animation demo: Fall down LayoutAnimation
<?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:delay="15%"
android:animationOrder="normal"
/>
@patrick-elmquist
patrick-elmquist / example.java
Last active May 5, 2021 11:44
Enter animation demo: Re run LayoutAnimation
private void runLayoutAnimation(final RecyclerView recyclerView) {
final Context context = recyclerView.getContext();
final LayoutAnimationController controller =
AnimationUtils.loadLayoutAnimation(context, R.anim.layout_animation_fall_down);
recyclerView.setLayoutAnimation(controller);
recyclerView.getAdapter().notifyDataSetChanged();
recyclerView.scheduleLayoutAnimation();
}
@patrick-elmquist
patrick-elmquist / item_animation_from_right.xml
Last active June 23, 2018 05:06
Enter animation demo: Slide from the right demo
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/anim_duration_long">
<translate
android:interpolator="@android:anim/decelerate_interpolator"
android:fromXDelta="100%p"
android:toXDelta="0"
/>
@patrick-elmquist
patrick-elmquist / item_animation_from_bottom.xml
Last active August 14, 2021 09:37
Enter animation demo: Slide from bottom demo
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/anim_duration_long">
<translate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta="50%p"
android:toYDelta="0"
/>
@patrick-elmquist
patrick-elmquist / grid_layout_animation_from_bottom.xml
Last active July 26, 2017 18:06
Enter Animation demo: Slide bottom GridLayoutAnimation example
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation
xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/item_animation_from_bottom"
android:animationOrder="normal"
android:columnDelay="15%"
android:rowDelay="15%"
android:direction="top_to_bottom|left_to_right"
/>
@patrick-elmquist
patrick-elmquist / item_animation_from_bottom.xml
Last active July 26, 2017 18:06
Enter animation demo: Slide form bottom item animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/anim_duration_long">
<translate
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromYDelta="50%p"
android:toYDelta="0"
/>
@patrick-elmquist
patrick-elmquist / GridRecyclerView.java
Last active September 8, 2020 08:04
Enter animation demo: GridRecyclerView implementation
/**
* RecyclerView with support for grid animations.
*
* Based on:
* https://gist.github.com/Musenkishi/8df1ab549857756098ba
* Credit to Freddie (Musenkishi) Lust-Hed
*
* ...which in turn is based on the GridView implementation of attachLayoutParameters(...):
* https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/GridView.java
*
@patrick-elmquist
patrick-elmquist / stacktrace.txt
Last active July 26, 2017 18:07
Enter animation demo: GridLayoutAnimation vs RecyclerView stacktrace
com.patrickiv.demo.enteranimationdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.patrickiv.demo.enteranimationdemo, PID: 19510
java.lang.ClassCastException: android.view.animation.LayoutAnimationController$AnimationParameters cannot be cast to android.view.animation.GridLayoutAnimationController$AnimationParameters
at android.view.animation.GridLayoutAnimationController.getDelayForView(GridLayoutAnimationController.java:299)
at android.view.animation.LayoutAnimationController.getAnimationForView(LayoutAnimationController.java:323)
at android.view.ViewGroup.bindLayoutAnimation(ViewGroup.java:4584)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3453)
at android.view.View.draw(View.java:17240)
at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3985)
...
@patrick-elmquist
patrick-elmquist / example.java
Last active August 3, 2018 07:14
Enter animation demo: Apply GridLayoutAnimation
int resId = R.anim.grid_layout_animation_from_bottom;
LayoutAnimationController animation = AnimationUtils.loadLayoutAnimation(ctx, resId);
recyclerview.setLayoutAnimation(animation);
@patrick-elmquist
patrick-elmquist / example.xml
Last active July 26, 2017 18:14
Enter animation demo: Using GridRecyclerView
<com.patrickiv.demo.enteranimationdemo.recyclerview.GridRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutAnimation="@anim/grid_layout_animation_from_bottom"
/>