Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying animations while changing visibility of a view

I am having a HorizontalScrollView in my application and I am playing with its visibility very frequently(VISIBLE and GONE). So what I want is, instead of suddenly making it visible and invisible, can I apply some kind of animation or something so that it will start becoming visible and invisible in a sliding manner ?

Any help or suggestions would be highly appreciated. Thanks in advance.

like image 789
Vipul J Avatar asked Dec 15 '22 18:12

Vipul J


2 Answers

You could try this:

Animation animation = new TranslateAnimation(0,0,0,1000);
animation.setDuration(1000);
yourButtonorImage.startAnimation(animation);

To make it visible or invisible you could use setAnimationListener. In onAnimationEnd, make it visible or invisible. NOt sure if this is what you meant..Hope it helps..

like image 135
omi0301 Avatar answered Feb 15 '23 02:02

omi0301


Try this..

youView.setVisibility(View.VISIBLE);
ObjectAnimator anim = ObjectAnimator.ofFloat(youView, "alpha", 0f, 1f);
anim.setDuration(1000);
anim.start();

Api Level Restrictions Applied.

like image 37
Rohit Sharma Avatar answered Feb 15 '23 02:02

Rohit Sharma