Search code examples
androidlistviewandroid-lint

How does setting baselineAligned to false improve performance in LinearLayout?


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?


Solution

  • 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)