Greets ,
How can I get the Coordinates of the Bitmap not of the screen. Screen Coordinates got by event.getX(),event.getY() methods but not getting coordinates of the bitmap. Please help anyone.
Greets ,
How can I get the Coordinates of the Bitmap not of the screen. Screen Coordinates got by event.getX(),event.getY() methods but not getting coordinates of the bitmap. Please help anyone.
You can't get the coordinates of the bitmap directly. You need to calculate to yourself. Use the position of the ImageView, and with that you can handle it.
Of course, when you are after Activity onCreate you can acces to any inflated (active) views parameter. Exemple. ImageView a; a.getPaddingBottom(); Like all coordinats (left right etc...) After this you need the Height and Width of the ImageView. Nah, when you know the views position, hegiht and width you can calculate.
Example:
look at the following code if the answer is too short:
Android: Detect touch on actual image in ImageView
the code replaces the padding and max height coding of this answer and replaces it with the actual width and height of the displayed image using getWidth() and getHeight(). And uses the screen width and height to calculate its position. If you want more detailed answers for your problem you should give more information such as where did you draw the bitmap... did you define it at the activity XML or did you draw it at a random location such as at the X and Y coordinates of a touch event, the answer depends on that information.
Notice that this code only works when the image is displayed at the horizontal center of the screen. Or use top and bottom if the image is displayed at the vertical center of the screen.