简体   繁体   中英

Android - Can I improve the performance of a 1-level-view-hierarchy-layout using include / merge tags?

Since I discovered ConstraintLayout, I achieved converting all my layouts to very fast loading 1-level-view-hierarchy-layouts. That means, all views are direct childs of the root layout.

However, I noticed that many views are aligned and styled in a equal pattern and have the same constraints to their next views etc. So I am wondering if I could improve the performance even more by defining such repeating groups of views in a second xml file and use the include- and merge-tag to include them multiple times in my layout.

Would this make sence and would it improve the performance? If yes, when would this be worth doing if I had a pattern of 3 TextViews (Starting at how many replications?)

I don't believe that there is a need to try and improve constraintLayouts performance, it's super fast and easy layout to use.
From what you said here - " improve the performance even more by defining such repeating groups of views", this really sounds like the job for fragments. and don't forget that if you want to use fragments you will have to set the fragment layout - so you didn't actually save work.
So generally with constarintLayout, if you work smartly with this layout - performance should not be a problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM