View.getLocationInWindow() only returns Y (and sometimes not even X)

by Romain Guy » Fri, 29 Jan 2010 06:52:52 GMT


Sponsored Links
 You are probably calling getLocationInWindow() before the layout happened.



>



View.getLocationInWindow() only returns Y (and sometimes not even X)

by ClarkBattle » Fri, 29 Jan 2010 06:53:19 GMT


 Sorry, in that first example I meant;

Log.i("Where?","x=" + loc[0] + " y=" + loc[1] );

not

Log.i("Where?","x=" + where[0] + " y=" + where[1] );

Copy/paste user error :)

--


Sponsored Links


View.getLocationInWindow() only returns Y (and sometimes not even X)

by ClarkBattle » Fri, 29 Jan 2010 06:54:38 GMT


 But its in onStart() while the layout happens in onCreate().  There is
no onFinishInflate() for Activities.  How do i make sure that the
inflation has happened?




> >



Other Threads

1. Crash on gesture recognize

I got a crash with the following stack trace:

E/AndroidRuntime( 6709): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 6709): java.lang.IllegalArgumentException:
Comparison method violates its general contract!
E/AndroidRuntime( 6709): at java.util.TimSort.mergeHi(TimSort.java:
864)
E/AndroidRuntime( 6709): at java.util.TimSort.mergeAt(TimSort.java:
481)
E/AndroidRuntime( 6709): at
java.util.TimSort.mergeCollapse(TimSort.java:406)
E/AndroidRuntime( 6709): at java.util.TimSort.sort(TimSort.java:210)
E/AndroidRuntime( 6709): at java.util.TimSort.sort(TimSort.java:169)
E/AndroidRuntime( 6709): at java.util.Arrays.sort(Arrays.java:2500)
E/AndroidRuntime( 6709): at
java.util.Collections.sort(Collections.java:1952)
E/AndroidRuntime( 6709): at
android.gesture.InstanceLearner.classify(InstanceLearner.java:84)
E/AndroidRuntime( 6709): at
android.gesture.GestureStore.recognize(GestureStore.java:134)
E/AndroidRuntime( 6709): at
android.gesture.GestureLibrary.recognize(GestureLibrary.java:64)
E/AndroidRuntime( 6709): at
com.contapps.android.search.SearchResults.onGesturePerformed(SearchResults.java:
130)

Line 130 in my code is:
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
and it is the first line in onGesturePerformed(GestureOverlayView
overlay, Gesture gesture).

Any idea what's wrong and what checks can I perform on gesture before
sending it to recognize to avoid this crash?

Thanks,
Mor
@ Contapps.

-- 

2. Smoothing out a line on a canvas.

I'm trying to draw out a race track in a map overlay.  I have a series
of locations that define the track.  I have the drawing working fine
just using canvas.drawLine() from one point to the next.  But,
understandably, this looks kind of choppy.  Is there a decent way to
smooth the line out?

-- 

3. glReadPixels() crashes on the HTC Desire

4. Urgent Help on Single instance of the activity

5. How can I stop File write operation when sdcard is going to be umounted

6. layar's platform

7. how to create a semi transparent image for the camera overlay?