10

According to the doc, the first is

Interface definition for a callback to be invoked when the layout bounds of a view changes due to layout processing.

and the second is

Interface definition for a callback to be invoked when the global layout state or the visibility of views within the view tree changes.

///

But they seem pretty similar to me. I was even able to use both of them interchangeably. Can someone give me a practical example of the usage of them? Thanks

user2062024
  • 3,541
  • 7
  • 33
  • 44

1 Answers1

21

An OnLayoutChangeListener is a listener for a specific View and will trigger only when that View goes through a layout pass (i.e. onLayout() is called).

An OnGlobalLayoutListener watches the entire hierarchy for layout changes (so registering one of these on any View in a hierarchy will cause it to be triggered when any View in that hierarchy is laid out or changes visibility).

Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274