Giter Site home page Giter Site logo

recycleview-with-imageview-and-animation-in-android's Introduction

RecycleView-With-ImageView-And-Animation-In-Android

Demo:

giphy3

down_to_up.xml

<translate
    android:fromYDelta="50%p"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:toYDelta="0" />

<alpha
    android:fromAlpha="0"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:toAlpha="1" />

up_to_down.xml

<translate
    android:fromYDelta="-25%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toYDelta="0" />

<alpha
    android:fromAlpha="0"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toAlpha="1" />

<scale
    android:fromXScale="125%"
    android:fromYScale="125%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="100%"
    android:toYScale="100%" />

left_to_right.xml

<translate
    android:fromXDelta="-100%p"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toXDelta="0" />

<alpha
    android:fromAlpha="0.5"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:toAlpha="1" />

right_to_left.xml

<translate
    android:fromXDelta="100%p"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toXDelta="0" />

<alpha
    android:fromAlpha="0.5"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:toAlpha="1" />

Now lets create the layoutAnimation for each of these animation sets.

layout_animation_down_to_up.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/down_to_up"
android:animationOrder="normal"
android:delay="15%" />

layout_animation_up_to_down.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/up_to_down"
android:animationOrder="normal"
android:delay="15%" />

layout_animation_left_to_right.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/left_to_right"
android:animationOrder="normal"
android:delay="15%" />

layout_animation_right_to_left.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/right_to_left"
android:animationOrder="normal"
android:delay="15%" />

Setting Layout Animation in XML and Programmatically

We can set the Layout Animation on RecyclerView in XML in the following way:

 <android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"                                        
android:layoutAnimation="@anim/layout_animation_right_to_left"
/>

Programmatically:

int resId = R.anim.layout_animation_right_to_left; LayoutAnimationController animation = AnimationUtils.loadLayoutAnimation(context, resId); recyclerView.setLayoutAnimation(animation);

In order to re-run the animation or in case the data set of the RecyclerView has changed the following code is used: Copy

 final LayoutAnimationController controller =
 AnimationUtils.loadLayoutAnimation(context, R.anim.layout_animation_right_to_left);
recyclerView.setLayoutAnimation(controller);
recyclerView.getAdapter().notifyDataSetChanged();
recyclerView.scheduleLayoutAnimation();

recycleview-with-imageview-and-animation-in-android's People

Contributors

dinesh2510 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.