I implemented some gesture detection code so that I could detect when a line was drawn in my list (which is in FrameLayout).
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { int itemId = MainActivity.this.getListView().pointToPosition((int) e1.getX(),(int) e1.getY()); Offer order = (Offer)MainActivity.this.getListView().getAdapter().getItem(itemId); View v = MainActivity.this.getListView().getChildAt(itemId); } }
I want to display a view on top of a vertex row with a set of context sensitive options for that row.
My problems are that the following methods:
v.getTop() v.getBottom()
return the correct values only before scrolling the view. Perhaps I could do some calculations to work out offsets using scroll positions, etc., but I also noticed that I only get values when I scroll the line that is visible on the screen to start. If I scroll down the list and then scroll the line (which was not originally off the screen), then these methods return null values.
The methods below seem to suffer from the same problem ...
v.getLocationOnScreen(loc) v.getLocationInWindow(loc)
Ultimately, I am looking to find the distance between the top of the visible listView and the row that was skipped. Then I will use this distance to add the view to the parent FrameLayout with the appropriate height fill (so that it covers the line with slots).
Any help would be greatly appreciated!
android
Damian Jan 26 2018-01-26 13:43
source share