Android:如何检查ScrollView内部的视图是否可见?我有一个ScrollView它拥有一系列的Views..我希望能够确定视图当前是否可见(如果视图的任何部分当前由ScrollView)。我希望下面的代码能够做到这一点,令人惊讶的是它没有做到这一点:Rect bounds = new Rect();view.getDrawingRect(bounds);Rect scrollBounds = new Rect(scroll.getScrollX(), scroll.getScrollY(),
scroll.getScrollX() + scroll.getWidth(), scroll.getScrollY() + scroll.getHeight());if(Rect.intersects(scrollBounds, bounds)){
//is visible}
3 回答
猛跑小猪
TA贡献1858条经验 获得超8个赞
Rect scrollBounds = new Rect();scrollView.getHitRect(scrollBounds);if (imageView.getLocalVisibleRect(scrollBounds)) { // Any portion of the imageView, even a single pixel, is within the visible window} else { // NONE of the imageView is within the visible window}
- 3 回答
- 0 关注
- 314 浏览
添加回答
举报
0/150
提交
取消