How to create the delay of 1 sec before set the alpha of View?
Solution 1
In your animation xml
file you can use android:startOffset
attribute:
android:startOffset int. The amount of milliseconds the animation delays after start() is called.
Solution 2
Can't you use the
android:startOffset int. The amount of milliseconds the animation delays after start() is called.
in your animation xml?
See the animation resource documentation.
Solution 3
Suppose you are using the view .animate()
method, you can set the start offset:
view.animate().x(100)
.setDuration(5000)
.setStartDelay(1000);
Solution 4
Handler is a good technique to achieve this.
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
view.startAnimation(animation);
}
}, 1000);
Solution 5
In your case you can simply do like this
hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide);
hideMenu.setStartOffset(1000);
menuLayout.startAnimation(hideMenu);
menuLayout.setVisibility(View.GONE);
In this case you can control dynamically value of the start time from the activity
Related videos on Youtube
Shreyash Mahajan
About Me https://about.me/sbm_mahajan Email [email protected] [email protected] Mobile +919825056129 Skype sbm_mahajan
Updated on July 09, 2022Comments
-
Shreyash Mahajan almost 2 years
In My Application i am going to set the alpha after one animation. As like:
hideMenu = AnimationUtils.loadAnimation( getApplication(), R.anim.menu_layout_hide); menuLayout.startAnimation(hideMenu); menuLayout.setVisibility(View.GONE);
But i want to set the delay of 1 Sec before the Alpha set th the View. as Because of that i am not able to see the Animation of that layout. So How it is possibe ?
Thanks.
-
Mori about 2 yearsPlease see this example: stackoverflow.com/a/71824377/12272687
-
-
Shreyash Mahajan over 12 yearsThanks for the reply. Let me try it.
-
duggu over 7 yearsif you do not mind , not making sense postDelayed in animation because animation itself have setStartDelay method.Please do not take my word as offense but i tell you what i feel.