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 -

  1. View inside another View in the centre-
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 -

  • With Complex UI where we can have more hierarchies, it is wise to use constraint layouts.
  • 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!

--

--

--

Googler since 2021 | Ex- Google Developer Expert, Android | Visit : https://thedroidlady.com/ to know more.

Recommended from Medium

Android 开发技术周报 Issue#300

Flutter Tutorial #1 — Form Validation.

Dynamic Color Curved Border in layout Android-studio

Reading NFC Tags with Android (Kotlin)

From expo init to Google Play Store

Income tax result screen which shows the income tax and superannuation amount.

Google Play Store Stuck Wait­ing for Down­load Issue

Handle LiveData Observer properly in ViewModel Testing

Bottom Navigation Bar with Jetpack Compose

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niharika Arora

Niharika Arora

Googler since 2021 | Ex- Google Developer Expert, Android | Visit : https://thedroidlady.com/ to know more.

More from Medium

How Integrated Ads Kit: Banner Ads (Java) ==Android Studio (Arctic Fox)==

How to maintain Android code test coverage

7 Pitfalls to avoid on your first Composable app

Jetpack Compose ScrollableTabRow Indicator Matches Width of Text