我想知道我的布局视图何时显示在物理屏幕上。您知道在一些使用ScrollView
的应用程序中,您必须向下滚动才能看到其他视图。我想知道什么时候像Button
或TextView
这样的视图或其他视图在物理屏幕上显示来做一些工作。提前致谢:)
试试这个:
Rect scrollBounds = new Rect();
scrollView.getHitRect(scrollBounds);
if (view.getLocalVisibleRect(scrollBounds)) {
// Any portion of the view, even a single pixel, is within the visible window
} else {
// NONE of the view is within the visible window
}