Adam Lee
Adam Lee

Reputation: 586

Android: How to trigger an event on a visibility change on a View?

In order to avoid lag and the bug in which a portion of a previous layout is still showing, I want to only set the visibility of a View to visible only when the previous layout is no longer visible. How do I attach a listener to see if the previous layout is no longer visible?

Upvotes: 0

Views: 1464

Answers (1)

Maybe you can use onVisibilityChanged ?

protected void onVisibilityChanged (View changedView, 
                int visibility)

Called when the visibility of the view or an ancestor of the view has changed.

Documentation link:

https://developer.android.com/reference/android/view/View#onVisibilityChanged(android.view.View,%20int)

Upvotes: 1

Related Questions