Is there a way to handle a view visibility change (say, from GONE to VISIBLE) without overriding the view?
Something like View.setOnVisibilityChangeListener();?
View.setOnVisibilityChangeListener();
You can use a GlobalLayoutListener to determine if there are any changes in the views visibility.
GlobalLayoutListener
myView.setTag(myView.getVisibility()); myView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int newVis = myView.getVisibility(); if((int)myView.getTag() != newVis) { myView.setTag(myView.getVisibility()); //visibility has changed } } });
1.4m articles
1.4m replys
5 comments
57.0k users