Search code examples
androidperformanceandroid-constraintlayoutandroid-tablelayout

TableLayout vs ConstraintLayout Performance


I couldn't find anything comparing the performance of the two. Would imitating a TableLayout with a ConstraintLayout perform better than a TableLayout on its own?


Solution

  • As TableLayout and TableRow both extend from LinearLayout, comparing them to a ConstraintLayout will be the same as comparing two nested LinearLayout with one ConstraintLayout.

    The Android documentation and this Android developers article describes the benefits of ConstraintLayout over other ViewGroup types.

    ConstraintLayout will outperform nested LinearLayout specially if they have defined weights, as it would be common in TableLayout.

    Layout weights require a widget to be measured twice. When a LinearLayout with non-zero weights is nested inside another LinearLayout with non-zero weights, then the number of measurements increase exponentially.