Example usage for android.view.animation Animation setDuration

List of usage examples for android.view.animation Animation setDuration

Introduction

In this page you can find the example usage for android.view.animation Animation setDuration.

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.example.demo_highlights.slidingmenu.fragment.PageFragment1.java

private LayoutAnimationController getListAnim() {
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(200);
    set.addAnimation(animation);// w w w  . j  a v  a  2  s . c  om

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(200);
    set.addAnimation(animation);

    Animation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    inAnimation.setDuration(200);
    inAnimation.setFillAfter(true);
    set.addAnimation(inAnimation);

    Animation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    outAnimation.setDuration(200);
    outAnimation.setFillAfter(true);
    // 
    LayoutAnimationController inController = new LayoutAnimationController(inAnimation, 0.3f);
    // 
    LayoutAnimationController outController = new LayoutAnimationController(outAnimation, 0.3f);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    return controller;
}

From source file:com.ua.max.oliynick.flicker.widgets.ScrollAwareFABBehavior.java

private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(null).start();
    } else {//from w ww .j  a  va  2s. c  o m
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_appear);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}

From source file:it.bellotti.android.materialdesignsample.ui.widget.ScrollAwareFABBehavior.java

private void animateFabIn(final FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(null).start();
    } else {/*from   w ww  .  j a va  2s. c  o  m*/
        Animation anim = new ScaleAnimation(0.0F, 0.0F, 1.0F, 1.0F);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.evandroid.musica.utils.RefreshButtonBehavior.java

public void animateIn(FloatingActionButton button) {
    if (!button.isEnabled())
        return;//from w  ww  .ja v  a2s. c om
    button.setVisibility(View.VISIBLE);
    visible = true;
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).translationY(0).setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.refresh_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}

From source file:de.uni_weimar.m18.anatomiederstadt.SplashActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    final PathView pathView = (PathView) findViewById(R.id.pathView);
    pathView.useNaturalColors();//from   w  w w. j a  v  a  2  s  . c o  m

    int pathDelay = 1000;
    int pathDuration = 2500;

    final Animation a = new AlphaAnimation(0.00f, 1.00f);
    a.setStartOffset(3500);
    a.setDuration(1000);

    //pathView.setSvgResource(R.raw.vitruvian_man_weimar_kk3);
    pathView.getPathAnimator().delay(pathDelay).duration(pathDuration)
            .interpolator(new AccelerateDecelerateInterpolator()).start();

    final ImageView logoImage = (ImageView) findViewById(R.id.logoImage);

    a.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            logoImage.setVisibility(View.VISIBLE);

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    launchMainActivity();
                }
            }, 1500);

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    logoImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            launchMainActivity();
        }
    });

    logoImage.startAnimation(a);

}

From source file:com.timecontents.smartnotice.animate.AnimatedListViewAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (position > _objects.size()) {
        return null;
    }/*from   w ww.j av a  2  s  .co  m*/

    View v = convertView;
    ViewHolder holder;
    if (v == null) {
        v = _inflater.inflate(_resourceId, parent, false);

        holder = new ViewHolder();
        holder.tvTitle = (TextView) v.findViewById(R.id.tv_notice_title);
        holder.tvDate = (TextView) v.findViewById(R.id.tv_notice_date);
        holder.tvContent = (LinkEllipseTextView) v.findViewById(R.id.tv_notice_content_ellipse);
        holder.imgContent = (ImageView) v.findViewById(R.id.img_notice_content);
        holder.imgFileIcon = (ImageView) v.findViewById(R.id.img_notice_file_icon);
        holder.imgType = (ImageView) v.findViewById(R.id.img_notice_type_icon); // ? ?  ?

        v.setTag(holder);
    } else
        holder = (ViewHolder) v.getTag();

    JSONObject object = _objects.get(position);
    _objectMapper.bindObjectToView(object, holder, v);

    if (v != null) {
        Animation animation = new TranslateAnimation(0, 0, (position > lastPosition) ? 100 : -100, 0);
        animation.setDuration(400);
        v.startAnimation(animation);
    }
    lastPosition = position;

    return v;
}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade in./*from   w w  w  .  jav  a  2  s . com*/
 */
public void fadeIn() {
    Animation anim = new AlphaAnimation(maxBrightness, minBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade out./*from   w ww.j  a va 2 s  . co  m*/
 */
public void fadeOut() {
    this.view.setAlpha(1f);
    Animation anim = new AlphaAnimation(minBrightness, maxBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.architjn.acjmusicplayer.elements.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.abc_slide_out_bottom);
    anim.setInterpolator(INTERPOLATOR);//  w  ww .j  a  v  a 2 s  . co  m
    anim.setDuration(600L);
    anim.setAnimationListener(new Animation.AnimationListener() {
        public void onAnimationStart(Animation animation) {
            ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
        }

        public void onAnimationEnd(Animation animation) {
            ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
            button.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(final Animation animation) {
        }
    });
    button.startAnimation(anim);
}

From source file:com.github.kaninohon.poi.ui.widget.ScrollAwareFABBehavior.java

private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(null).start();
    } else {//from   w w  w. j  a  v a  2s .c o  m
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}