0

I have an ImageView and I make that element visiable by timer. Its became visable as quick as thought. But I dont know how to make it visiable gradually. For example first it`s transparent then became completely visable. How can i do that?! Here below my timer. How can i update it?!

final ImageView mImageView = (ImageView) findViewById(R.id.mobile);
                mImageView.setVisibility(View.INVISIBLE);
                if (position == 0) {
                    mImageView.postDelayed(new Runnable() {
                        public void run() {
                            if(mImageView!=null) mImageView.setVisibility(View.VISIBLE);
                        }
                    }, 3000);
                }
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193

1 Answers1

0

You can do this with Animation. Create a method such as:

private Animation fadeInAnimation() {
    Animation animation = new AlphaAnimation(0f, 1.0f);
    animation.setDuration(1000); // in milliseconds, change to whatever you want
    animation.setFillEnabled(true);
    animation.setFillAfter(true);
    return animation;
}

And call it when you make the ImageView visible:

mImageView.setVisibility(View.VISIBLE);
mImageView.startAnimation(fadeInAnimation());
mjp66
  • 4,214
  • 6
  • 26
  • 31