Android Api 22及以下 View onVisibilityChanged Listener Not Firing
解决办法
Android官方说明
原因
Restore app expectations around drawable visibility change timing
When we update drawable visibility has changed to be part of
View.onVisibilityChanged instead of an overload of
setVisibility. While this covers more cases that we were previously
missing, it also means that we now set drawable visibility from the
View constructor via the call chain view.setFlags to
view.onVisibilityChanged to drawable.setVisibility, resulting in us
passing a
initialized. (i.e. a Bad Thing.)
In general we
sort of thing as a part of view inflation - calling various non-final
setters that may invoke callbacks as needed rather than initializing
view fields directly. Unfortunately it also means that we can cause a
lot of hard to trace bugs and in the long run we should try to clean
up as much of it as we can.
In this case, some apps were expecting inflation to have finished
completely before any drawable visibility changed. If a view
visibility changes but it
callback?
The fix: no. We won
but we will dispatch it when a view becomes attached.
Also fix a bug where we could end up telling a view its visibility
changed to (INVISIBLE | GONE), which just doesn
Bug 20103422
Change-Id: Ifba54c36114e85cf64869afcca766c30d601a16c