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"
android:layout_width="wrap_content"
android:id="@+id/frame14"></FrameLayout>
    </RelativeLayout>
</LinearLayout>

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
say

(FrameLayout) f=(FrameLayout)findViewById(R.id.frame14);
int[] loc = new int[2];
f.getLocationOnScreen(loc);
System.out.println(loc[0]);
System.out.println(loc[1]);

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.

Thanks
Kavitha

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. a2dp (WAS fix alsa compilation problem Eclair)






Sorry find :( external/bluetooth for sure :)

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. AudioTrack sanity test

Hi.
I am trying to determine if I should go the ndk way to work on a music
synth app, but first wanted to do a sanity check in the java layer by
testing how many sine tones i could play concurrently, and so I tried
this. And it's pretty low: I can only play about 4 or 5 tones before
the obtainBuffer timeouts start increasing in number. Also, changing
the media volume while the tones are playing disrupts the output.
These are the basic settings for each of the tones:
- fs = 11025
- AudioFormat.CHANNEL_CONFIGURATION_MONO
- AudioFormat.ENCODING_PCM_8BIT
- AudioTrack.MODE_STREAM
I would like to know how one can best avoid obtainbuffer timeout
errors.

--~--~---------~--~----~------------~-------~--~----~

3. ActivityGroup and subactivities Lifetime.

4. AlertBuildeer Problem

5. QVGA854 AVD not displaying properly

6. Alternatives to using 'createScaledBitmap' when adding 3D

7. Why are iPhone apps prettier than Android apps?