How do include, merge, and ViewStub optimize deep layout nesting?

This tests Android view inflation and hierarchy flattening. A strong answer covers include for reuse, merge to strip redundant parents during inflation, and ViewStub for lazy-loading heavy views. A red flag is conflating them or citing XML brevity alone.
This tests deep knowledge of Android view inflation and how to flatten layout hierarchies while keeping modularity. A strong answer explains that include lets you reuse a layout file inside another, merge removes the redundant root ViewGroup when inflating a reusable layout so the host hierarchy stays flat, and ViewStub acts as a zero-cost placeholder until inflate is called for heavy or conditional views.
Read the original → developer.android.com
- #android
- #views
- #layout
- #performance
- #xml
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.