Reputation: 120334
How can I get notified when a layout pass has finished? Is there something like onLayoutFinished()
that I can implement or override somewhere?
From the View javadoc:
Layout is a two pass process: a measure pass and a layout pass. The measuring pass is implemented in measure(int, int) and is a top-down traversal of the view tree. Each view pushes dimension specifications down the tree during the recursion. At the end of the measure pass, every view has stored its measurements. The second pass happens in layout(int, int, int, int) and is also top-down. During this pass each parent is responsible for positioning all of its children using the sizes computed in the measure pass.
What I'd like is to execute some logic after the "second pass" has finished. In particular, I want to make some changes to a view, and then make changes to another view that depend of the frame (position and size) of the first view.
Upvotes: 2
Views: 3292
Reputation: 98501
You can simply override onLayout() and do whatever you need to do after calling super.onLayout(). You can also override onSizeChanged(), which will be invoked only when a layout pass changes the coordinates/size of a View.
Upvotes: 3