6

Get the Y coordinate of the top and bottom of ImageView

 2 years ago
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.
neoserver,ios ssh client

Get the Y coordinate of the top and bottom of ImageView

advertisements

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?

I am currently trying to optimize a few queries and scripts, and I wonder if there is a way to cut off a certain percentage of a MySQL Result Set? for example, I have a Query like this: SELECT TrackingID, OpenTime, FirstPoint FROM PointsTable I need

Draw the top and bottom lines on a view

I am trying to draw lines on the top and bottom edge of a UIView. But the line does not get drawn all the way to the right edge of the view controller. Following is the code I am using to draw the lines: - (void)addBorders { CALayer *upperBorder = [C

The background image in div is cut at the top and bottom when the page is too short

I'm super new at CSS, so this may be really simple. I've searched a bunch for the answer to this question, but I haven't found it yet. I would like the div, containing the logo to stretch and scale depending on the page size, and I pretty much have t

IOS 7 Black bars at the top and bottom (3.5 only)

I seem to have some across and interesting issue that I can not resolve. I have a app written in XCode 5 running ios 7.1. The app was working perfectly until I moved the folder location of the project. When I ran up the app on my phone the app worked

The top and bottom splitters do not appear in the Android list

The way I understand it, the divider defined for a listview should appear at the top and bottom of the list too, i.e. above the first item and under the last item. For some reason they don't appear in my listview: <?xml version="1.0" encoding

The top and bottom bars are not visible on iPhone Simulator

In the interface builder of iPhone i have selected the top and bottom bars. i can view both the bars in the View window but when i run the application my iPhone simulator is not showing both the bars. do i need to configure any or want to add any cod

The button icon is cut at the top and bottom

The top and bottom areas of my button are being cut off. It's allowing me only to have my icon be the same height as my button's text. I tried overflow hidden, I tried expanding the button padding. HTML: <div id="toprow"> <div id="

How do I remove a variable number of rows from the top and bottom of multiple HTML documents?

I have a large number of html documents that need a variable number of lines removed from the top and bottom. The part I want always starts with <div class="someclass"> and the bottom section always starts with <div class="bottomou

Dynamically creating elements at the top and bottom of the browser window

I'm using the following code to dynamically create an "overlay" <div> at the top and bottom of the browser window. $(function() { var winWidth = $(window).width(); var winHeight = $(window).height(); $('body').append('<div style="p

jQuery - DIV to move with the scrolling motion and the position of the stick at the top and bottom of the window

There may be already a jQuery plugin which can achieve this, but I can't find one to do exactly what I'm after. If there is, just point me to the tutorial, thanks. My problem I have is that I have very long page content, and my sidebar is not visible

Android ScrollView adds extra padding at the top and bottom of the child image view

I have a problem with rendering a ScrollView. Essentially, the layout is fixed header and footer with a scrollview in the middle. The idea is that when the screen keyboard is activated for the content EditText the image can be scrolled if the height

Bootstrap 3 tab navigation on the top and bottom of the page?

I'm building a site in Bootstrap 3 and have figured out that you can indeed place both a top nav-tab and bottom nav-tab section on the same page. These two separate tab menus will trigger the same tab content areas to show/hide. Doing this works just

need to show the list of items between, the top and bottom bar,

I want to create a layout in which two bars , one at top , another at bottom will be there, and one listview between these two bars, But question here is , between the top and bottom bar, i need to show list of items, where both top and bottom bar wi

Creating borders at the top and bottom of certain contents

I'm trying to do so using CSS --------------------- SOME CONTENT HERE --------------------- so what I basically want is that the border is just at the top and bottom of whatever content there is inside (most preferably a <p></p>) Here is some

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK