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

  • Home
  • SEARCH
  • 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 9217775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:42:31+00:00 2026-06-18T02:42:31+00:00

I’m trying to display a frame to frame animations using AnimationDrawable when clicking a

  • 0

I’m trying to display a frame to frame animations using AnimationDrawable when clicking a ImageView. But my animation happens only once when I click the ImageView. I’m using xml for the animation.

Animation xml:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
  <item android:drawable="@drawable/scorepopup1" android:duration="100" />
  <item android:drawable="@drawable/scorepopup2" android:duration="100" />
  <item android:drawable="@drawable/scorepopup3" android:duration="100" />
  <item android:drawable="@drawable/scorepopup4" android:duration="100" />
  <item android:drawable="@drawable/invipopup" android:duration="100" />

</animation-list>

Here’s my xml for the button and the container of the animation image:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="70dp"
    android:layout_height="50dp"
    android:layout_alignParentRight="true" 
    android:layout_margin="5dp">

    <ImageView
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:background="@drawable/bd"
    android:layout_margin="10dp"
    android:onClick="checkGem" 
    android:contentDescription="bd"/>


    <ImageView
        android:id="@+id/scorePopup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp" />
</LinearLayout>

checkGem Method:

ImageView popup1 =  (ImageView) findViewById(R.id.scorePopup);

popup1.setBackgroundResource(R.drawable.popup1_animation);
AnimationDrawable frameAnimation2 = (AnimationDrawable) 

popup1.getBackground();
frameAnimation2.start();

My problem is the animation displays only once, But I want it to animate everytime I click. Any ideas?

  • 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-18T02:42:32+00:00Added an answer on June 18, 2026 at 2:42 am

    Place a stop() call on the ImageView‘s AnimationDrawable background right before the start() call:

    //...
    AnimationDrawable frameAnimation2 = (AnimationDrawable) popup1.getBackground();
    frameAnimation2.stop();
    frameAnimation2.start();
    

    When you first click the ImageView the animation will run but at the end it will find itself in a state where it thinks is still running. In that state, calling start() will simply be ignored. The stop() method “resets” that state and the AnimationDrawable will run from the start again.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.