[英]How to listen the Viewable change of a View on Android
I am creating a custom view(extends WebView). 我正在创建一个自定义视图(扩展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.
例如,该视图位于ScrollView下,当用户滚动时,该视图将被滚动出屏幕。 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? 无论如何,有没有听得见的变化?
Since WebView
inherits from View
it seems to me you can override the View
methods to monitor what you like. 由于
WebView
从View
继承,所以在我看来,您可以重写View
方法以监视您喜欢的内容。 Check developer.android.com's View documentation and check the methods under 'Implementing a Custom View'. 查看developer.android.com的View文档,并检查“实现自定义视图”下的方法。 For your scrolling example it seems like you can override the
onScrollChanged
method. 对于您的滚动示例,似乎可以覆盖
onScrollChanged
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.