0

When i try to make a man run in android by displaying his images with his his legs in different position the animation does not look very good.It appears as two different images switching between one another.It does not look uniform.Is there any other way to implement animation in android.

7
  • take a look about animation-drawable , and using Handler
    – Houcine
    Jun 25, 2011 at 9:43
  • I am using a surface view.So any animation will be in the onDraw() method.Is it possible to use the animation drawable in the onDraw() method.
    – Sab
    Jun 25, 2011 at 9:43
  • i think that you can use it , i've never work with surfaceView and canvas, but i think that you can use animation drawable on it
    – Houcine
    Jun 25, 2011 at 9:47
  • Is there any sample code anywhere to which i can refer to.
    – Sab
    Jun 25, 2011 at 9:48
  • you can do a simple search in the stackoverflow : feref this : stackoverflow.com/search?q=animation+drawable
    – Houcine
    Jun 25, 2011 at 9:56

1 Answer 1

0

See, you are loading two images switching in order to show man walking. For that switching to look better as walking man, you should add alpha animation on the imageview and the animation should happen when there is image switch occuring. Hope this could improve your userInterface of "walking man"...

create a res/anim/anim.xml animation file in your project:

<?xml version="1.0" encoding="utf-8"?>
<alpha
    android:fromAlpha="0"
    android:toAlpha="1"
    android:startOffset="0"
    android:duration="2"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    xmlns:android="http://schemas.android.com/apk/res/android">
</alpha>

And in Activity.java file write small piece of code when you are switching:

...
Animation a = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.anim);
img.startAnimation(a);
....

And, to improve for best animation, you should use more intermediate images. Hope this could solve your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.