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

后端 未结 14 2082
自闭症患者
自闭症患者 2020-11-22 16:42

I have a ScrollView which holds a series of Views. I would like to be able to determine if a view is currently visible (if any part of it is curre

14条回答
  •  再見小時候
    2020-11-22 17:34

    I faced the same problem today. While Googling and reading Android reference I found this post and a method I ended up using instead;

    public final boolean getLocalVisibleRect (Rect r)
    

    Nice of them not to only providing Rect but also boolean indicating if View visible at all. On negative side this method is undocumented :(

提交回复
热议问题