判断scrollview中某子控件是否可见

Android: how to check if a View inside of ScrollView is visible?

Solutions:

Rect scrollBounds = new Rect();
scrollView.getHitRect(scrollBounds);
if (childView.getLocalVisibleRect(scrollBounds)) {
    //子控件至少有一个像素在可视范围内
    // Any portion of the childView, even a single pixel, is within the visible window 
} else { 
    //子控件完全不在可视范围内
    // NONE of the childView is within the visible window 
} 

你可能感兴趣的:(android,scrollview,位置,可见)