Reputation: 329
I want to know when a view of my layout is showing in physical screen. You know in some apps that uses ScrollView
, you must scroll down to see other views. I want to know when a view like Button
or TextView
or another view is showing in physical screen to do some job. Thanks in advance:)
Upvotes: 2
Views: 1816
Reputation: 4936
Try this:
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
}
Upvotes: 3