Revert "Removes the usage of the ViewTreeObserver class"

This reverts commit e9e1201df60f9b6f98e9356433cd963718a00ea5.