What is CollapsingToolbarLayout
's toolbarId
for? I can't find any description in Google and my AppBarLayout/CollapsingToolbarLayout works properly without it.
I figured it out myself by looking into the source code of CollapsingToolbarLayout
(CTBL
).
CTBL
in fact doesn't need a toolbarId
set explicitly because it searches for a toolbar in its child views if no id is set. However, by setting a toolbarId
we can optimize our code because then the CTBL
doesn't have to search itself (which happens repeatedly).
https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/appbar/CollapsingToolbarLayout.java