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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:24:00+00:00 2026-06-13T23:24:00+00:00

I am trying to rotate an imagebutton to 360 by clicking itself but it

  • 0

I am trying to rotate an imagebutton to 360 by clicking itself but it doesn’t work

I am using xml file like this..

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="72dp"
        android:layout_height="72dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="83dp"
        android:layout_marginTop="103dp"
        android:clickable="true"
        android:src="@drawable/cute" />
</RelativeLayout>

and java code like this…

package com.example.testapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.RotateAnimation;
import android.widget.ImageButton;

public class MainActivity extends Activity implements OnClickListener {


    ImageButton img;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        img = (ImageButton) findViewById(R.id.imageView1);



    }
    public void onClick(View v) {
        // TODO Auto-generated method stub
        RotateAnimation ra =new RotateAnimation(0, 360);
        ra.setFillAfter(true);
        ra.setDuration(0);

        img.startAnimation(ra);

    }

}

my aim of application is using 9 img btn develop and puzzle find game….

  • 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-13T23:24:01+00:00Added an answer on June 13, 2026 at 11:24 pm

    Your code works just fine. the problem is : you set duration to 0. You can’t see it happen because if you rotate 360 degrees its ending position and starting position will be identical . so set the duration 1000(a second) or more to see the animation actualy happening.

    just try:

    ra.setDuration(1000);
    

    And you also did not set the onClick listener of img.

    just try:

    img .setOnClickListener(new OnClickListener() {
    
        public void onClick(View arg0) {
            //animation here
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to rotate the log file everyday by using the DailyRollingFileAppender, but
I'm trying to rotate an SVG <polygon> (or any other element) using this: var
I'm trying to rotate a rectangle by rotating its points , using this code
I am trying to rotate an image using slider..its working well but when i
I'm trying to rotate a block of text slightly like below: Can this be
I am trying to rotate the MapView. And could rotate it just like this
I am trying to rotate a text to 270 degrees, using this code: /*
I am trying to rotate a graphic, but for some reason it won't work.
I'm trying to rotate an image around the center. This works generally using RotateAnimation,
I am trying to rotate vectors using matrices, but got confused. I thought all

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.