Get the Y coordinate of the top and bottom of ImageView
source link: https://www.codesd.com/item/get-the-y-coordinate-of-the-top-and-bottom-of-imageview.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Get the Y coordinate of the top and bottom of ImageView
I have an image view which is contained within a relative layout. I am trying to get the screen y coordinates of the top of the image view and the screen y coordinates of the bottom of the image view. I have tried this:
float yMin = (float)levelH.getTop();
float yMax = (float)levelH.getBottom();
float yMin seems almost correct. I am translating another image view (IM2) up and down this image view(IM1). So I am trying to set a limit on how far (IM2) can translate up and down. So my thinking was to get the y top and bottom of (IM1) I can set those as max and min.
Anyone know how to do this?
ps Im using android accelometer to move (IM2)
getTop()
ansd getBottom()
look at coordinates within it's parent. To get coordinates of it's position on the screen you can use getLocationOnScreen
Use it like this:
int[] coords = {0,0};
view.getLocationOnScreen(coords);
int absoluteTop = coords[1];
int absoluteBottom = coords[1] + view.getHeight();
Related Articles
Cut 13% at the top and bottom of a MySQL query?
Draw the top and bottom lines on a view
The background image in div is cut at the top and bottom when the page is too short
IOS 7 Black bars at the top and bottom (3.5 only)
The top and bottom splitters do not appear in the Android list
The top and bottom bars are not visible on iPhone Simulator
The button icon is cut at the top and bottom
How do I remove a variable number of rows from the top and bottom of multiple HTML documents?
Dynamically creating elements at the top and bottom of the browser window
jQuery - DIV to move with the scrolling motion and the position of the stick at the top and bottom of the window
Android ScrollView adds extra padding at the top and bottom of the child image view
Bootstrap 3 tab navigation on the top and bottom of the page?
need to show the list of items between, the top and bottom bar,
Creating borders at the top and bottom of certain contents
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK