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 5948219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:04:36+00:00 2026-05-22T17:04:36+00:00

I have been working on learning animations in Android, and, based on the tutorials,

  • 0

I have been working on learning animations in Android, and, based on the tutorials, it’s fairly easy so far. However, I wanted to take the animations a step further than what the tutorials teach.

I wanted to simulate the rolling of a die. Here is my code to add the die to the view.

<ImageButton android:id="@+id/dice" android:clickable="true"
    android:onClick="rollDie" android:src="@drawable/dice_sides"
    android:layout_alignParentRight="true" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:background="@null" />

The source, dice_sides, is a level-list.

Adding the initial animation was easy. Within the rollDie method in the Activity, I did this:

/**
 * Roll of the die.
 * 
 * @param view
 *            The view that is being acted upon.
 */
public void rollDie(View view) {
    // Setup the animation.
    Animation move = AnimationUtils.loadAnimation(view.getContext(),
            R.anim.move);
    View dice = findViewById(R.id.dice);
    dice.setAnimation(move);
    move.start();
}

That works fine. The die image shakes back and forth.

What I want to have happen is the die to then display various numbers as it moves through the animation, until it stops on the last part of the animation. Unfortunately, I can’t find much on how to do a second animation along with the first. Someone mentioned the use of handlers, but I don’t quite understand how to use them in this situation. If anybody could point me in the right direction, I would appreciate it.

(For the record, here is dice_sides.)

<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:maxLevel="0" android:drawable="@drawable/die.1" />
    <item android:maxLevel="1" android:drawable="@drawable/die.2" />
    <item android:maxLevel="2" android:drawable="@drawable/die.3" />
    <item android:maxLevel="3" android:drawable="@drawable/die.4" />
    <item android:maxLevel="4" android:drawable="@drawable/die.5" />
    <item android:maxLevel="5" android:drawable="@drawable/die.6" />
</level-list>
  • 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-05-22T17:04:37+00:00Added an answer on May 22, 2026 at 5:04 pm

    It took me a little bit to figure it out, but I finally determined how to get both parts of the animation working together. (The tip on handlers was spot on.) I wrote a blog post discussing how to get this to work. It can easily be extrapolated to more advanced animations.

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

Sidebar

Related Questions

I am learning Android and have been working on an application that will need
I have been learning to use Emacs for a little while now. So far
I have been working on learning C++ and Qt4 recently, but I have hit
I'm currently learning PHP and MySQL and I have been working from a basic
I'm learning mysql and have been trying to get this working, but an error
I've started learning C and pointers and I've been working on tutorials on the
I'm working on an ASP.Net MVC project and have been learning a few little
I have been working on my own library/framework for the learning experience for a
I have been using Grails for last 3 weeks (learning and working). I have
I have been working on a web services related project for about the last

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.