| Calculating initial View dimensions in an Activity Note that a ViewTreeObserver instance associated with a View instance can become invalid while that View is still alive. From the View.getViewTreeObserver javadocs: Thus, if you have previously added a listener to a ViewTreeObserver instance and now wish to remove it, it is easiest to call getViewTreeObserver on the corresponding View instance again to receive a fresh ViewTreeObserver instance. (Checking isAlive on an existing instance is more work for little benefit; if the ViewTreeObserver is no longer alive, you'll be fetching that fresh reference anyway!) |