2010-05-18 132 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中調用它,它將不起作用。

相關問題