Find position of ImageView relative to the image it's displaying

So here's the problem. I am displaying a big image in ImageView and need to find it's position relative to the image. Like this:

â•‘ Image                         â•‘ 
║──>╔═════════════╗             ║
â•‘   â•‘ ImageView   â•‘             â•‘
â•‘   â•‘             â•‘             â•‘
║   ╚═════════════╝             ║
â•‘                               â•‘
â•‘                               â•‘

Any help?

UPD: Since there were some misunderstandings I will explain the problem in detail.

I have an image. A Bitmap actually. I am displaying it in an ImageView with CENTER scale type. Assume that the image is bigger than the ImageView, so only a part of the image is displayed. I want to find the position of this part relative to the whole image.

Asked by: Ada492 | Posted: 25-01-2022

Answer 1

getTop() , getLeft() on the child view won't solve it ? And if views are not parent-child , but have same parent - do it for each view and do the math

Answered by: Abigail606 | Posted: 26-02-2022

Answer 2

The image render starts from the top-left corner of the image so even if the image is bigger then the imageview, you will always see the top-left corner.

Answered by: David803 | Posted: 26-02-2022

Similar questions

imageview - Displaying an image coming from database through web service in Android

I am trying to display an image using ImageView in Android. The image data is coming from Database through a Web Service. All other values other than image is successfully visible on android screen. I tried following code : Bitmap bm=BitmapFactory.decodeStream((InputStream)response.getProperty(7)); image.setImageBitmap(bm); But i am getting class cast exception as: 12-30 1...

android - Displaying ImageView in a definite place on layout

developers. Is anybody know, what functions can I use to display an ImageView in a correct place on it`s parent Layout?

android - Error on displaying image in imageview

This one has made me bite my nails. I parsed image URL's from XML into an arraylist.I am displaying images in table layout along with some text. I am using the following code in activity for displaying image : Bitmap bm=DownloadImage(; icon.setImageBitmap(bm); Here piciterator is iterating arraylist containing URL's. Here is DownloadImage function ...

android - ImageView expands when displaying an image

I'm trying to make a layout with 10 equal height rows, each row containing an ImageView and a TextView. When I put an image into the ImageView, I would like it scaled to retain the same aspect and fit inside the ImageView, not changing the ImageView size or the height of the containing TableRow. The problem I have is that when I load an image into the ImageView, the ImageView seems to expand, and it also changes...

imageview - android getting error while displaying image from url

When i'm displaying image from url with using below code, application is taking too much time to load images from server. Application is hanging up if we have 8-10 images to load. Bitmap mbmp = BitmapFactory.decodeStream(new"urlname").openStream()); Imageview_ref.setImageBitmap(mbmp); and getting this in Logcat 09-15 11:34:14.265: ERROR/Cu...

java - Displaying .jpg in an ImageView from the web

I'm not sure what I'm doing wrong here - it seems that somethings is wrong with fetch() as the application didn't force close when I commented that section out (And anything that needed it's return value of course). Could use a second pair of eyes if you all could be so helpful :)! This is all within my main Activity's class. image.xml (R.layout.image) is has just an ImageView named "imageView1" pub...

android - Displaying Cards on an imageView

Hello i am trying to display cards on an image view one slightly overlaying the other. I was thinking of using padding, but i am not sure how to use it. Thanks. Here is how i display my cards. while(bl.dealerIterator.hasNext() == true) { dealerCards.setImageResource(; }

java - Android ImageView Is Not Displaying Image?

Can anyone tell me why the following code is not working? The Image does not appear at all. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" <ImageView android:src="@drawable/splashscreen" and...

Android Imageview from URL in Fragment not displaying

Exactly what the title says. I'm trying to display an imageView from a URl in a fragment, but nothing shows up. Android doesn't crash, and the layout is just empty. I have internet permissions enabled in my manifest. <uses-permission android:name="android.permission.INTERNET" /> Java code here public class InboxFragment extends Fragment { @Override public View onCrea...

android - ImageView not displaying Bitmap on real device

I get an Bitmap from internal storage or from the internet. When I try to display it in a ImageView, it works on different Emulator versions but not on my Galaxy S I9000. The Bitmap simply doesn't show up. protected void onPostExecute (Bitmap bmp) { progressBar.setVisibility(View.INVISIBLE); if (bmp != null) { imageView.setImageBitmap(bmp); imageView.setVisibility(View.VISIBLE); ...

android - Displaying a default date in a EditText widget

How would I display the current date in the text of a EditText widget dynamically at runtime? Thanks patrick

android - Displaying thumbnails of images (present at different locations in the sdcard) in a listview

I have several images present in different folders in my sdcard. I would like to display a list of thumbnails. So what I have done is while rendering any row in the list I read the file in an input stream, get the byte array, decode it to obtain a bitmap and set it in an imageview. So far so good. But when I scroll the list, the list scrolls in jerks. I believe this is because decoding a bitmap from byte array tak...

android - Issue with displaying TabHost Layout in new Intent

I am having an issue with using TabHost in a new Intent of type TabActivity which I hope you can point me in the right direction. Funnily it works fine when I try to view it in the original Intent : setContentView(R.layout.main) I get a "forced closed" and within logcat, I get the following error even though my Tabhost id = "@android:id/tabhost": 02-18 22:23:11.937: ERROR/AndroidRuntime(5...

Android: Displaying Images From SDcard

I have an app on the market that displays all photos from the user's SDcard in a gallery. Initially I had out of memory issues, but alleviated those by increasing the inSampleSize in the BitmapFactory options. However, I still have intermittent reports of images not displaying, in some cases none at all. There seems to be a larger proportion of Droid Eris users having problems. Here is the method that loads all photos and ...

Black screen is displaying in Android

I opened my application after I am not doing any kind of operation. I leave the mobile 5 min. After 5 min when I touch the my application it is showing black screen. Is there any way to avoid this idle state?

Android Spinner not displaying list items

I think I am going crazy right now. I am trying to create a spinner populated by a datatable but for some reason the dropdown list items text is not being displayed. I have looked all over and have seen other posts with people having this same problem. Can anyone help?? speciesList = (Spinner) findViewById(; spinnerCursor = nsfdb.fetchAllSpecies(); startManagingCursor(spinnerCu...

android - Displaying popup images on button click

Please refer the image given in the url My query is, How can I display the messages corresponding to the rounded buttons and the table row , when I click on the rounded button with question mark. I know, I ha...

android - Displaying a bitmap of arbitrary size without running out of memory

How do I display an image of arbitrary size without OOMing or downscaling the image. I dont want to downscale due to zooming and dragging of the picture? If it isnt possible to display an image of arbitrary size, how do I determine the maximum possible size of the image to display, without causing a OOM?

Displaying the Time in AM/PM format in android

I am getting the time using a time picker and displaying the time in the text view using following code... private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Toast.makeText(SendMail.this, "Your Appointment time is "+hourOfDay+":"+minute, Toast.LENGTH_SHORT).show(); ...

java - How to add the coding for displaying the address when a particular set of latitude and longitude is selected into the following codes?

package net.learn2develop.PopularAttractions; import; import java.util.List; import java.util.Locale; import; import; import; import; import android.location.Address; import android.location.Geocoder; import android.os.Bundle; import android.u...

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android