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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:28:44+00:00 2026-05-26T09:28:44+00:00

I want to rotate a picture (Bitmap within a ImageView) around his center. This

  • 0

I want to rotate a picture (Bitmap within a ImageView) around his center.
This works pretty well by using the preRotate method with the values width/2 and height/2 of the Bitmap and 1 or -1 degree as rotation factor.

But I implemented the rotation functions as Buttons. Everytime the Button “rotate right” is pressed the Imageview rotates one degree to the right and so on. It would be nice to press the Button and while the Button is pressed the picture starts rotating until the button is released.

I’ve read some threads here in which these feature is implemented as OnTouchListener instead of OnClickListener, but it does not work for me. If I implement loops within the MotionEvent.ACTION_DOWN event then they are infinite. If I don’t use loops then the event is only handled once (like in OnClickListener).

So how can I increment/decrement the rotation factor while a button is pressed?

  • 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-26T09:28:45+00:00Added an answer on May 26, 2026 at 9:28 am

    Short answer: You need to implement a corresponding MotionEvent.ACTION_UP to stop the adding. ACTION_DOWN is only ever fired once, when the user presses down. That’s why when you weren’t looping you only got one increment. What you need is a seperate thread to start doing the increments when a MotionEvent.ACTION_DOWN is done and stop them when MotionEvent.ACTION_UP is fired. Something like this should work.

    public MyActivity extends Activity{
    
    
      private bool continueIncrementing;
      private Runnable incrementerThread;
    
      //put this OnTouchListener on your button
       View.OnTouchListener downListener = new View.OnTouchListner(){
         public onTouch(View v, MotionEvent event){
           if(event == MotionEvent.ACTION_DOWN){
             startIncrmenting();
           }
           else if(event == MotionEvent.ACTION_UP){
             stopIncrementing();
           }
         }
       };
    
       private void startIncrmenting(){
         setIsIncrementing(true);
         new Thread(new Runnable() {
           public void run() {
             while(isIncrementing()){
              //do incrementing in here
             }
           }
         }).start();
       }
    
       sychronized private void stopIncrmenting(){
         setIsIncrementing(false);
       }
    
    
       sychronized private bool isIncrmenting(){
         return continueIncrementing;
       }
    
       synhronized void setIsIncrmenting(bool newSetting){
         continueIncrementing = newSetting;
       }
    
    
      //rest of your activity
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I find this pretty confusing. When you want to rotate a view, it's going
I want to rotate the below image on a center point using one finger
I want to rotate text on a JPanel using Graphics2D.. My code is this:
I want to rotate imageview with continuously looping on android.my code rotate is working
I have an object which I first want to rotate (about its own center)
I want to rotate a picture, in a way that it would work like
I have a picture in a PictureBox. I want to rotate it by any
I want to rotate an image continuously on page load. Code works fine for
I have a picture (bitmap) and I want to draw some shapes and rotated
I want to rotate imageview and then I want to start activity onClick of

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.