How does setting baselineAligned to false improve performance in LinearLayout?

Christopher Perry picture Christopher Perry · Feb 16, 2012 · Viewed 47.2k times · Source

I was just building some UI in xml, and Lint gave me a warning and said to set android:baselineAligned to false to improve performance in ListView.

The docs for the Lint changes that added this warning say

Layout performance: Finds LinearLayouts with weights where you should set android:baselineAligned="false" for better performance, and also finds cases where you have nested weights which can cause performance problems.

Can somebody explain why this improves performance, specifically when weight is involved?

Answer

Nima G picture Nima G · Feb 17, 2012

By setting android:baselineAligned="false" , you're preventing the extra work your app's layout has to do in order to Align its children's baselines; which can obviously increase the performance. (Fewer unnecessary operations on UI => Better performance)