android flyin imageview after a certain time - stack overflow.pdf

4
Stack Overflow sign up log in Questions Tags Users Badges Unanswered Ask 1 android flyin imageView after a certain time android animation android-imageview postdelayed The purpose I aming for is, that 2 seconds after my activity was started an ImageView (with an image) should flyIn to the view. But with the following code nothing happens. Am I on the right way or can I solve this completely different? What do I have to change that this works? Here is how my code looks: The animation I use is from here : Fly In Animation for a GridView But slightly changed: } }; _flyInTruckHandler.postDelayed(new Runnable() { public void run() { new flyInTruck(); } }, 2000); } class flyInTruck extends TimerTask { @Override public void run() { Animation anim = AnimationUtils.loadAnimation( getApplicationContext(), R.anim.flyin); findViewById(R.id.main_garbageTruck).setAnimation(anim); _flyInTruckHandler.sendEmptyMessage(0); anim.start(); } } } Read this post in our app!

Upload: shoaib-quraishi

Post on 07-Jul-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: android flyin imageView after a certain time - Stack Overflow.pdf

Stack Overflow sign up log in

Questions Tags Users Badges Unanswered Ask

1 android flyin imageView after a certain timeandroid animation android-imageview postdelayed

The purpose I aming for is, that 2 seconds after my activity was started an ImageView (with an image) should flyIn to the view. But with the followingcode nothing happens.

Am I on the right way or can I solve this completely different? What do I have to change that this works?

Here is how my code looks:

The animation I use is from here : Fly In Animation for a GridView But slightly changed:

} };

_flyInTruckHandler.postDelayed(new Runnable() { public void run() { new flyInTruck(); } }, 2000); }

class flyInTruck extends TimerTask {

@Override public void run() { Animation anim = AnimationUtils.loadAnimation( getApplicationContext(), R.anim.flyin); findViewById(R.id.main_garbageTruck).setAnimation(anim); _flyInTruckHandler.sendEmptyMessage(0); anim.start(); } } }

Read this post in our app!

Page 2: android flyin imageView after a certain time - Stack Overflow.pdf

1 Answer Order By Votes

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="true" > <scale android:duration="2500" android:fillAfter="false" android:fromXScale="0.0" android:fromYScale="0.0" android:interpolator="@android:anim/decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0" /> </set>

share improve this question

AskedJul 1 '12 at 5:31

Bruno Bieri 1,998 ● 4 ● 24 ● 41

0SOLUTION

Ok, I got it (so simple and I didn't thought about that before). I do not need that extra class "flyInTruck". I just can write it like this:

_flyInTruckHandler.postDelayed(new Runnable() { public void run() { Animation anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.flyin); findViewById(R.id.main_garbageTruck).setAnimation(anim); _flyInTruckHandler.sendEmptyMessage(0); anim.start(); } }, 2000);

share improve this answer

AnsweredJul 1 '12 at 5:38

Bruno Bieri 1,998 ● 4 ● 24 ● 41

Page 4: android flyin imageView after a certain time - Stack Overflow.pdf