wayne_bai
wayne_bai

Reputation: 1228

How to listen the Viewable change of a View on Android

I am creating a custom view(extends WebView). I want to listen the viewable state of the view.

Viewable state means whether or not the view is showing on the screen. I didn't mean the Visibility. Such as, the view is under a ScrollView, when user scroll and the view will be scrolled out of the screen. Its visibility is not change, it's still visible but is not viewable because it is scrolled out of the screen.

Is there anyway to listen the viewable change?

Upvotes: 1

Views: 549

Answers (1)

Scott
Scott

Reputation: 303

Since WebView inherits from View it seems to me you can override the View methods to monitor what you like. Check developer.android.com's View documentation and check the methods under 'Implementing a Custom View'. For your scrolling example it seems like you can override the onScrollChanged method.

Upvotes: 1

Related Questions