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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:31:59+00:00 2026-05-26T05:31:59+00:00

I have an ImageView containing a Bitmap image. The image is twice as big

  • 0

I have an ImageView containing a Bitmap image. The image is twice as big as its container. I have declared onScroll() to be able to move around the Bitmap image. How can I get the coordinates of the ImageView on the Bitmap image?

Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.image);
_iv.setImageBitmap(bm);
_iv.setAdjustViewBounds(true);
_iv.setMaxHeight(bm.getHeight());
_iv.setMaxWidth(bm.getWidth());
_iv.setScaleType(ImageView.ScaleType.CENTER);

Bitmap newBm = Bitmap.createScaledBitmap(bm, bm.getWidth() * 2, bm.getHeight() * 2, true);
_iv.setImageBitmap(newBm);
  • 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-26T05:32:00+00:00Added an answer on May 26, 2026 at 5:32 am

    I haven’t found an actual way to do this. Here’s the method I’ve used:

    Upon creating the ImageView, scroll to a known location.

    int ivX = 0;
    int ivY = 0;
    
    _iv.invalidate();
    _iv.scrollTo(ivX, ivY);
    

    This way I have the exact (x, y) coordinates of where I am. Then, I’ve implemented the onScroll() method and used the generated distances to recalculate my (x, y) coordinates:

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        //Add the scroll distance to the old X, Y coordinates
        ivX += distanceX;
        ivY += distanceY;
    
        //Scroll to the new location
        _iv.scrollTo(ivX, ivY);
    
        return false;
    } //End onScroll()
    

    In addition, to get a better understanding of how scrollTo() works and the relationship between the coordinates of the image and its container, follow this link to a different post of mine.

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

Sidebar

Related Questions

I have used ImageView's before and understand the different scale types that can be
I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?
I need a way to have a gray scale image in an ImageView and
I have an ImageView with a source image set in the xml using the
I have a Imageview in main.xml, how to set the bitmap the to the
I have an Activity with a layout containing a custom ImageView and a few
I have an ImageView in my application and I am loading the image in
I have an ImageView that you can use to do a one-finger pan, or
I have an imageview, which uses matrix to scale/drag an image. Now I want
I have a problem with a RelativeLayout containing two TextView s and a ImageView

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.