Lam Pham
Oct 19, 2020

Hello Andrés.

You can imagine that <merge> tag is like an inline function, not the reference of that function is invoked but codes in such function will be copied pasted to the caller block.

when using <merge>, we don't create a ViewGroup as container in that included layout but all the views within it will be contained directly in the root ViewGroup of caller layout. Thus, the caller layout stays always single-layered.

if we add a ViewGroup in included layout instead of a <merge> tag, then we have at least in total 2 layers, one ViewGroup is in included layout and the other is the root ViewGroup of the caller layout.

In my example, there is only a button so you can not see it clearly. However, you can place more Views without creating a specific ViewGroup.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Lam Pham
Lam Pham

No responses yet

Write a response