A Battle towards Performance -ConstraintLayout vs Other Layouts Part -3

Android performance

Now we already know various tools that can be used for measuring the performance of layouts with different ViewGroups we have in Android.

Here, I am sharing the result for different layouts testing performed on Coolpad and Android 6.0 Marshmallow.

Note: This may vary with the device as well as API level. Also, there are many updates to the layouts as well. Please perform the result on your end too.

I also created a Github project for your reference. You can check out the code for various layouts there.

Here are the results -

View Inside Another View in Center

2. RecyclerView with 100 Items

RecylerView with Items

3. Simple UI with TextViews and Images

UI with Image and Text

4. Complex UI with Images, Text, ScrollView, Buttons etc.

Traditional vs Constraint

Please Note:- Always measure your layout performance through systrace and GPU overdraw before finalizing any layout. These results can vary from device to device and with respect to the OS version too. On average, however, the results will remain the same.

Conclusion -

The complete analysis of the various layouts tells us -

  • If you are using LinearLayout with weights/RelativeLayout with hierarchies, replace them with Constraint layout.
  • For simple layouts with just one view centred on the screen, go for Frame layouts.
  • For simple screens, where you have to place views just horizontally and vertically, go for LinearLayout.

References -

Originally published here.

Please feel free to share your opinion in the comments.

If you liked this blog, hit the 👏 . Stay tuned for the next one!