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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:18:56+00:00 2026-06-09T17:18:56+00:00

I have been created the animation arrow. When I press the button then it

  • 0

I have been created the animation arrow. When I press the button then it rotate -45 degree and then goes back arrow.
My Question is: I want to stop the arrow at -45 degree. When I click the button again then it should move the arrow -45 to -90 and so on.
Please help me regarding this problem. thanks

I am placing code here.

<?xml version="1.0" encoding="utf-8"?>
 <set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">

        <rotate
            android:fromDegrees="0"
            android:toDegrees="-45"
            android:toYScale="0.0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="400"


             />
    </set>

hyperspace_jump.xml

package kh.qasim;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class CustomAnimationActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        final ImageView image = (ImageView) findViewById(R.id.imageView1);
        final Animation hyperspaceJump = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
        Button btn = (Button) findViewById(R.id.button1);
        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                    image.startAnimation(hyperspaceJump);

            }
        });

    }
}

CustomAnimationActivity.java

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<ImageView android:id="@+id/imageView1" android:src="@drawable/up" android:layout_width="203dp" android:layout_height="148dp"></ImageView>
</LinearLayout>

main.xml

  • 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-09T17:18:57+00:00Added an answer on June 9, 2026 at 5:18 pm

    First, if you want to prevent you image to revert to previous state afterb the animation, you need to use :

    anim.setFillAfter(true);
    

    Also, in order to be able to change orientation dynamically, you should create your animation programmatically, instead of doing it from an XML file :

    RotateAnimation anim = new RotateAnimation(fromDegrees, toDegrees);
    

    Use fromDegress and toDegrees variable to control the start and end orientation of your object. For instance, you could put save the current orientation in a variable that you would call currentOrientation. So, you just need to call :

    RotateAnimation anim = new RotateAnimation(cuurentOrientation, currentOrientation - 45);
    

    Then start the animation like you did before.

    At the end of the animation, just store the new orientation in currentOrientation.

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

Sidebar

Related Questions

What are the current best practices with git branches that have been created to
Strings are immutable, meaning, once they have been created they cannot be changed. So,
Basically, I am using Wireshark looking at captures that have been created previously. How
I am to process single PDFs that have each been created by 'merging' multiple
@Solved The two subquestions I have created have been solved (yay for splitting this
I have been following mozilla developer network's docs and created a transition for my
I have an FBO which has been created in the following way: glGenRenderbuffers(1, &m_depthStencilBuffer);
I created an app and have been testing it against targetSdk 14. The spinner
I have a TextReader which has been created by a black-boxed system so I
I have an object that hasn't been created yet (so it has no ID),

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.