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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:41:46+00:00 2026-06-02T16:41:46+00:00

I am implementing code to rotate image by touch listener. While user touching and

  • 0

I am implementing code to rotate image by touch listener. While user touching and rotating the image, it is getting rotate and at the same time it is getting ‘Zoom-Out’. I need image rotation without zoom-out. This is the code I implemented.

public class SeekBarCustomized extends Activity implements OnTouchListener{

    //VerticalSeekBar mVerSeekbar;
    ImageView mIvRotateImage;
    private float y=0;
    int r =0;

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

        mIvRotateImage = (ImageView) findViewById(R.id.ivImgView);
        mIvRotateImage.setOnTouchListener(this);

}
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub
        //double r=Math.atan2(event.getX()-mIvRotateImage.getWidth()/2, mIvRotateImage.getHeight()/2-event.getY());
        //double r=Math.atan2(event.getX(), event.getY());
        int rotation=(int)Math.toDegrees(r);
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                break;
            case MotionEvent.ACTION_MOVE:

                r = r + 2;

                rotate(v, event);
                break;
            case MotionEvent.ACTION_UP:
                break;
        }//switch       

        return true;
    }

private void rotate(View v, MotionEvent event) {
        LayoutParams mParams = (LayoutParams) mIvRotateImage.getLayoutParams();
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
                R.drawable.increcircle);
        int w = bitmap.getWidth();
        int h = bitmap.getHeight();
        Matrix matrix = new Matrix();
        matrix.preRotate(r);
        Bitmap rotaBitmap = Bitmap.createBitmap(bitmap, 0, 0, 200, 200, matrix,
                true);
        BitmapDrawable bdr = new BitmapDrawable(rotaBitmap);

        int x = mParams.leftMargin;
        int y = mParams.topMargin;
        mParams.leftMargin = 50;
        mParams.topMargin = 50;
        mIvRotateImage.setImageDrawable(bdr);
        mIvRotateImage.setLayoutParams(mParams);
    }
}

My Xml file is

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

<ImageView android:id="@+id/ivImgView"
    android:layout_width="200px" android:layout_height="200px"
    android:layout_marginTop="50px" android:layout_marginLeft="50px"
     android:src="@drawable/increcircle"/>
</RelativeLayout>
  • 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-02T16:41:47+00:00Added an answer on June 2, 2026 at 4:41 pm
    I used this code snippet.
    
    //android:scaleType="center" 
    in <ImageView /> tag at xml file/
    By using this Image is rotating but not scaling.
    
    
    <ImageView android:id="@+id/ivImgView"
        android:layout_width="200px" android:layout_height="200px"
        android:layout_marginTop="50px" android:layout_marginLeft="50px"
         android:src="@drawable/increcircle" android:scaleType="center"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the following code for implementing zoom image in Android: public class MyActivity extends
I am implementing some code and I want to run it in regular time(auto
I'm implementing a basic speedometer using an image and rotating it. However, when I
I am implementing Code Generation for WindowsForm control at Design-Time, using a Custom CodeDomSerializer.
While implementing the code from this question on my project I realized there's 3
hi all i am implementing android code for getting the contacts from contact list
I'm implementing some code generators, i would like to know if there's any way
I'm implementing a code in matlab to solve quadratic equations, using the resolvent formula:
Am having a number of problems implementing the code from the Washington Post site
What best practices should be observed when implementing HDL code? What are the commonalities

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.