Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8368871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:29:39+00:00 2026-06-09T13:29:39+00:00

All- I have a simple app in which I want a man to walk

  • 0

All- I have a simple app in which I want a man to walk across the screen. Right now the animation is happening in one place like a sticky note flip book. In other words the frames are changing in one place like a spinning wheel would. My question is how can I get the animation to progress forward (at my desired pace) as well as change frames? Here is my code concerning this issue:

public void start(View v) {  
    ImageView img = (ImageView)findViewById(R.id.imageView); 
    img.setBackgroundResource(R.drawable.animation); 
    AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();                
    frameAnimation.start();
}

Thanks for your time and effort!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:29:41+00:00Added an answer on June 9, 2026 at 1:29 pm

    You could do something like this, using your own image(the image of the man):

    Main Class:

    package com.android.animation;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class Main extends Activity 
    {
    
        Animation myView;
    
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            myView = new Animation(this);
            setContentView(myView);
        }
    }
    

    Animation Class:

    package com.android.animation;
    
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.view.View;
    
    public class Animation extends View
    {
    Bitmap gBall;
    float changingY;
    
    public Animation(Context content)
    {
        super(content);
    
        gBall = BitmapFactory.decodeResource(getResources(), R.drawable.ball);
        changingY = 0;
    }
    
    @Override
    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);
        canvas.drawColor(Color.BLACK);
        canvas.drawBitmap(gBall, (canvas.getWidth()/2), changingY, null);
        if(changingY < canvas.getHeight())
            changingY += 10;
        else
            changingY = 0;
    
        invalidate();
    }
    }
    

    XML file:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
    
    </LinearLayout>
    

    In fact, if you want you can go ahead and copy paste my code and see how it works(make sure to put an image in the drawable-hdpi folder)… you should be able to use it as a template for your project. Hope it helps!

    P.S You could of course, change the ChangingY variable to ChangingX (for example; of course you would have to change a couple other things like the drawBitmap() method.. not hard though) to make the ball move in a horizontal line… see how it works out for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple web application, for which I want all responses with
I have lately been developing a very simple app for iOS with PhoneGap. All
I have a simple image gallery here . All I want to do is
I have a simple table view which is editable. All I need the user
I have a simple iPhone app that Im learning and I want to have
I have a very simple app that has one CoreData Entity with a circular
I have a Flex 3 app which I want to instrument to report errors
I have a very simple WebView in my app which displays a Welcome dialog.
I have written a simple database driven app in C# which uses a 2
I have a simple metro style app where I want to drag 16 images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.