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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:35:04+00:00 2026-05-24T09:35:04+00:00

I am Rotating image on MotionEvent. and also image is getting shrink when i

  • 0

I am Rotating image on MotionEvent. and also image is getting shrink when i rotate it. i want to show Alert Dialog when move event is not more..

here i post my code…

private ProgressBar distanceBar;
private Button back;
private ImageView setAccuracy;
float currentDegrees = 0;
float currentDistance;
float totalDistance = 1000;
float totalDegree = 360;

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

    back = (Button) findViewById(R.id.back);
    distanceBar = (ProgressBar) findViewById(R.id.errand_progress);
    distanceBar.setMax(1000);
    setAccuracy = (ImageView) findViewById(R.id.errandAnim);
    OnTouchListener backListener = new OnTouchListener() {
        public boolean  onTouch  (View  v, MotionEvent  event) {
            if (event.getAction()==MotionEvent.ACTION_UP){
                finish();
            }
            return false;
        }
    };
    back.setOnTouchListener(backListener);
    setAccuracy.setOnTouchListener(onTableTouched);
}
public android.view.View.OnTouchListener onTableTouched = new android.view.View.OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {

        switch (event.getAction()) {
           case MotionEvent.ACTION_MOVE:
                if (currentDegrees > 360) {
                    currentDegrees = 0;
                }
                currentDegrees = currentDegrees + 1;
                updateRotation(currentDegrees);
                System.out.println("Current Degree is:--->" + currentDegrees);
                currentDistance = (currentDegrees * totalDistance)
                        / totalDegree;
                System.out
                        .println("Current Distance is:--->" + currentDistance);
                int progress = (int) currentDistance;
                distanceBar.setProgress(progress);
                break;

           case MotionEvent.ACTION_CANCEL:
            AlertDialog.Builder choice = new Builder(getParent());
            choice.setTitle("Error");
            choice.setMessage("message");
            choice.setPositiveButton("Ok",
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            return;
                        }
                    });
            choice.create().show();
            break;
        }

        return true;
    }
};
private void updateRotation(double rot) {
    float newRot = new Float(rot);
    Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.anim1);
    int width = bitmapOrg.getWidth();
    int height = bitmapOrg.getHeight();
    int newWidth = 200;
    int newHeight = 200;
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    int centerX = width/2;
    int centerY = height/2;

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    matrix.postRotate(newRot);
    matrix.postTranslate(centerX, centerY);
    matrix.preTranslate(-centerX, -centerY);
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width, height, matrix, true);
    BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
    setAccuracy.setImageDrawable(bmd);

}

}

how can i overcome this problem?

Thanks…

  • 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-24T09:35:04+00:00Added an answer on May 24, 2026 at 9:35 am

    Use the MotionEvent.ACTION_UP in place of MotionEvent.ACTION_CANCEL in your case.

    case MotionEvent.ACTION_UP:
            AlertDialog.Builder choice = new Builder(getParent());
            choice.setTitle("Error");
            choice.setMessage("message");
            choice.setPositiveButton("Ok",
                    new DialogInterface.OnClickListener() {
    
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            return;
                        }
                    });
            choice.create().show();
            break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting problem when I tried to move the after rotating the same image.
I have an image drawable. i rotating the image like a progress bar. <rotate
I m rotating Image in onFling(MotionEvent e1, MotionEvent e2, final float velocityX, final float
Currently i am using UIRotationGestureRecognizer to rotate my image and my image currently rotating
I am rotating my image with the following code: CGAffineTransform rotate = CGAffineTransformMakeRotation( [ratio
I have an image that rotating in a counter clockwise direction. Now, I want
I want to have an image or DIV to start rotating on click similar
When we rotate any object like Image then its x and y will also
I have rotating back ground image after 20 seconds with the fadeIn and fadeOut.
I'm having trouble roating an image around itself using Canvas. Since you can't rotate

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.