Reputation: 15849
Using a layoutanimation on one of my views.
android:layoutAnimation="@anim/animate_layout"
The animation is done each time one enters that view. It will however not run if that view was already active and the user changed to another application and then returned to it. In order to do that, I need to overwrite the onresume()
method and call it from there.
How can I call the layoutAnimation from within the code in order to run it again for the whole layout?
Upvotes: 0
Views: 604
Reputation: 1
I'm also trying to get my animation to start over when the user gets to se the layout again. I get force close with this code implemented.
public void onResume(){
super.onResume();
View layout = findViewById(R.layout.main);
Animation animation = AnimationUtils.loadAnimation(CrookTranslate.this, R.anim.fade_from_left);
layout.startAnimation(animation);
}
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/from_left"
android:id="@+id/fade_from_left"
android:delay="3.0"
/>
enter code here
Upvotes: 0
Reputation: 200090
Another option, besides what Pentium10 suggested, would be trying to do this:
Animation animation = AnimationUtils.loadAnimation(ctx, android.R.anim.fade_out);
target.startAnimation(animation);
Where ctx
could be something like YourActivity.this
, and target is the View
you want to animate.
Upvotes: 1