2010-05-18 126 views
3

我有一系列CompoundButtons的Horizo​​ntalScrollView。我想找到给定子视图的(x,y)。 getLocationOnScreen() getLocalVisibleRect() getChildVisibleRect()Horizo​​ntalScrollView中子视图的位置

这样的::我已经尝试使用 视图tmpView = this.findViewById(viewId); Rect hitRect = new Rect();
tmpView.getLocalVisibleRect(hitRect);

hitRect始终为0,0 - 0,0。

我需要x,y主要是滚动到特定的子视图。任何帮助是极大的赞赏。谢谢。

回答

1

你在做OnCreate的getLocalVisibleRect()吗?在使用getLocalVisibleRect之前,您需要等到android完成布局设置后,如果在OnCreate中调用它,它将不起作用。

相关问题