need help in getting screen coordinates of a view

by kavitha » Mon, 23 Mar 2009 08:04:46 GMT

Sponsored Links
 Hii All,

I am developing a game in android and i want to capture screen
coordinates of a view(ImageView) which is embedded in frame.

Hierarchy is
<LinearLayout android android:layout_height="fill_parent"
android:layout_width="fill_parent" >
      <RelativeLayout android:layout_height=fill_parent"
android:layout_width="fill_parent" >
            <FrameLayout android:layout_height="wrap_content"

At run time i am attaching two image views for frame layout.I wanted
to capture screen coordinates of frame layout.But Couldnt do it.if i

(FrameLayout) f=(FrameLayout)findViewById(;
int[] loc = new int[2];

I get Null Pointer Exception for getLocationOnScreen() method.

If I try to get f.getLeft() and f.getRight() they return as 0 coordinates.

Can anyone please tell me how to find location on screen of a view.

It is very urgent.Please help.



Other Threads

1. Webview - fill out an HTTP Form and submit programatically?

An alternative approach might be to use HttpClient and submit directly to
the URL the form does, passing in the form attributes with your call and
correct values. You will probably have to look at the page source of the
site you are trying to get into tho.

On Tue, Jan 19, 2010 at 9:55 PM, Maps.Huge.Info (Maps API Guru) <


2. Sold WTS: Hero white seken murah


Ateng makan kayu...
Sent from my Anjroid

"Indonesian Android Community [id-android]" 

Join,  visit the following page:

3. (Updated) (wts) XL unlimited 100rb

4. How enable AVD Camera?

5. how to output audio directly into hardware in andriod, video could user surfaceclient.

6. (WTI) Lomba desain logo & banner berhadiah Motorola CLIQ (khusus yg berdomisili di Indonesia)

7. Webview - fill out an HTTP Form and submit programatically?