tags:

views:

67

answers:

1

Hi all, I have a HorizontalScrollView with a series of CompoundButtons. I want to find the (x,y) for a given child view. I have tried using: getLocationOnScreen() getLocalVisibleRect() getChildVisibleRect()

like this: View tmpView = this.findViewById(viewId); Rect hitRect = new Rect();
tmpView.getLocalVisibleRect(hitRect);

the hitRect is always 0,0 - 0,0.

I need the x,y mainly to scroll to a particular child view. Any help is greatly appreciated. Thanks.

A: 

Are you doing the getLocalVisibleRect() in OnCreate? You need to wait until android is finished setting up the layout before using getLocalVisibleRect, if you call it in OnCreate it won't work.

QRohlf