1. Download our Official Android App: Forums for Android!

Apps Combing Tween with frame animation

Discussion in 'Android Development' started by zeeshan87, Aug 31, 2011.

  1. zeeshan87

    zeeshan87 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Aug 31, 2011

    Aug 31, 2011
    3
    0
    5
    I'm new to the android development, and working my way through android
    tutorials available on Android website more specifically relating to
    animation. Now I know how to apply tween and frame by frame
    animations, but I can't figure out how to combine these two animations
    to run simultaneously example of which could be an animating
    character(frame by frame) walk across the screen(translate).
    I tried putting the both the animation-list for frame by frame
    animation and translate animation under the Set tag of my
    animation.xml, file and running using the following code.


    ImageView iv = (ImageView) findViewById(R.id.imageView1);
    iv.setBackgroundResource(R.anim.animation); //where animation is the
    name of my animation xml
    AnimationDrawable anim = (AnimationDrawable) iv.getBackground();
    anim.start();


    But it throws an exception at setBackgroudResource.

    A tutorial on how to do that would be highly appreciated.
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    the setBackgroudResource method for an ImageView takes as its parameter a pointer to a Drawable. In your code, you are trying to supply an Animation object as a parameter. This is why it isn't working.
     
  3. zeeshan87

    zeeshan87 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Aug 31, 2011

    Aug 31, 2011
    3
    0
    5
    okay....but still how I could combine tween with frame by frame animation? I tried to google it but didn't found anything worthwhile.
     
  4. zeeshan87

    zeeshan87 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Aug 31, 2011

    Aug 31, 2011
    3
    0
    5
    This is the third place where I asked this question but still no answer. Is it really that difficult or not possible at all?
     
  5. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Not many people use Android's built-in animation class. Most people opt to use OpenGL for both 2d and 3d graphics.
     
  6. Velvet Void

    Velvet Void Lurker
    Rank:
    None
    Points:
    25
    Posts:
    7
    Joined:
    Aug 29, 2011

    I think the reason this is not working is because you have the animation in R.anim, which is the folder for view animations involving scaling, rotating, etc, whereas it should be in R.drawable, which is the folder for drawable animations.

    This is just my guess after reading the code at the bottom of this:
    View Animation | Android Developers ,
    because everything else seems to line up correctly with the source

    Hope that helps
     

Share This Page

Loading...