0

I saw an app, whose icon behavior in the navigationView delay it's visibility (Fade In- animation), yet my API for phone is 19.

My question is, how can I access to these icons to delay its visibility? Is it possible to implement it without using third party library?

RoCkDevstack
  • 3,517
  • 7
  • 34
  • 56

1 Answers1

1

For your view in Java you can do something like this -

Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new DecelerateInterpolator()); //add this
fadeIn.setDuration(1000);

Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
fadeOut.setStartOffset(1000);
fadeOut.setDuration(1000);

AnimationSet animation = new AnimationSet(false); //change to false
animation.addAnimation(fadeIn);
animation.addAnimation(fadeOut);
View.startAnimation(animation);

If you want to use only one if you wish to. You can even stop it by calling clearing it

View.clearAnimation();

OR other way

For XML, in your res/anim folder make a file, suppose name is fadein.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
  android:interpolator="@android:anim/linear_interpolator">
  <alpha
      android:fromAlpha="0.1"
      android:toAlpha="1.0"
      android:duration="2000"
      />
</set>

And in java

Animation animationFadeIn = AnimationU

tils.loadAnimation(this, R.anim.fadein);
View.startAnimation(animationFadeOut);

Use startAnimation() in a method where navigation becomes visible

Jimit Patel
  • 4,265
  • 2
  • 34
  • 58
  • I will test this first, thank you for your time. What is tils by the way and is `View` refer to my navigationView. I have no background in animation, it's my first time. – RoCkDevstack Jul 15 '16 at 10:46
  • `View` = your `ImageView` where icons are placed or it can be even your `TextView` but definitely I won't do that on `NavigationView` else that effect will be on `NavigationView` instead of at required place. – Jimit Patel Jul 15 '16 at 10:48