Android Open Source - AndroidImageSlider Description Animation






From Project

Back to project page AndroidImageSlider.

License

The source code is released under:

MIT License

If you think the Android project AndroidImageSlider listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.daimajia.slider.library.Animations;
/*from  w  ww  . j  a  va 2 s  . com*/
import android.view.View;

import com.daimajia.slider.library.R;
import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.animation.ValueAnimator;
import com.nineoldandroids.view.ViewHelper;

/**
 * A demo class to show how to use {@link com.daimajia.slider.library.Animations.BaseAnimationInterface}
 * to make  your custom animation in {@link com.daimajia.slider.library.Tricks.ViewPagerEx.PageTransformer} action.
 */
public class DescriptionAnimation implements BaseAnimationInterface {

    @Override
    public void onPrepareCurrentItemLeaveScreen(View current) {
        View descriptionLayout = current.findViewById(R.id.description_layout);
        if(descriptionLayout!=null){
            current.findViewById(R.id.description_layout).setVisibility(View.INVISIBLE);
        }
    }

    /**
     * When next item is coming to show, let's hide the description layout.
     * @param next
     */
    @Override
    public void onPrepareNextItemShowInScreen(View next) {
        View descriptionLayout = next.findViewById(R.id.description_layout);
        if(descriptionLayout!=null){
            next.findViewById(R.id.description_layout).setVisibility(View.INVISIBLE);
        }
    }


    @Override
    public void onCurrentItemDisappear(View view) {

    }

    /**
     * When next item show in ViewPagerEx, let's make an animation to show the
     * description layout.
     * @param view
     */
    @Override
    public void onNextItemAppear(View view) {

        View descriptionLayout = view.findViewById(R.id.description_layout);
        if(descriptionLayout!=null){
            float layoutY = ViewHelper.getY(descriptionLayout);
            view.findViewById(R.id.description_layout).setVisibility(View.VISIBLE);
            ValueAnimator animator = ObjectAnimator.ofFloat(
                    descriptionLayout,"y",layoutY + descriptionLayout.getHeight(),
                    layoutY).setDuration(500);
            animator.start();
        }

    }
}




Java Source Code List

com.daimajia.slider.demo.ChildAnimationExample.java
com.daimajia.slider.demo.MainActivity.java
com.daimajia.slider.demo.TransformerAdapter.java
com.daimajia.slider.library.SliderAdapter.java
com.daimajia.slider.library.SliderLayout.java
com.daimajia.slider.library.Animations.BaseAnimationInterface.java
com.daimajia.slider.library.Animations.DescriptionAnimation.java
com.daimajia.slider.library.Indicators.PagerIndicator.java
com.daimajia.slider.library.SliderTypes.BaseSliderView.java
com.daimajia.slider.library.SliderTypes.DefaultSliderView.java
com.daimajia.slider.library.SliderTypes.TextSliderView.java
com.daimajia.slider.library.Transformers.AccordionTransformer.java
com.daimajia.slider.library.Transformers.BackgroundToForegroundTransformer.java
com.daimajia.slider.library.Transformers.BaseTransformer.java
com.daimajia.slider.library.Transformers.CubeInTransformer.java
com.daimajia.slider.library.Transformers.DefaultTransformer.java
com.daimajia.slider.library.Transformers.DepthPageTransformer.java
com.daimajia.slider.library.Transformers.FadeTransformer.java
com.daimajia.slider.library.Transformers.FlipHorizontalTransformer.java
com.daimajia.slider.library.Transformers.FlipPageViewTransformer.java
com.daimajia.slider.library.Transformers.ForegroundToBackgroundTransformer.java
com.daimajia.slider.library.Transformers.RotateDownTransformer.java
com.daimajia.slider.library.Transformers.RotateUpTransformer.java
com.daimajia.slider.library.Transformers.StackTransformer.java
com.daimajia.slider.library.Transformers.TabletTransformer.java
com.daimajia.slider.library.Transformers.ZoomInTransformer.java
com.daimajia.slider.library.Transformers.ZoomOutSlideTransformer.java
com.daimajia.slider.library.Transformers.ZoomOutTransformer.java
com.daimajia.slider.library.Tricks.FixedSpeedScroller.java
com.daimajia.slider.library.Tricks.InfinitePagerAdapter.java
com.daimajia.slider.library.Tricks.InfiniteViewPager.java
com.daimajia.slider.library.Tricks.ViewPagerEx.java