Hello. I think In your example it will be better to add aList.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener) on Activity or Fragment Resume and remove it historyList.getViewTreeObserver().removeGlobalOnLayoutListener(onGlobalLayoutListe ner); on Pause.
Activity