Unnecessary use of CoordinatorLayouts

It feels like Google is seriously promoting the use of CoordinatorLayouts these days. They even released (unfortunately, I can’t seem to locate the link for it) an entire blog/website dedicated to teach little tips and tricks to properly using the CoordinatorLayout.

CoordinatorLayouts are great. I like them. When you start a new Android project and create a new empty Activity, Android Studio will even autogenerate a new XML layout file with a CoordinatorLayout. They make implementing certain Material design easy to implement and given that you actually know how to use the layout properly, makes laying out elements on your screen very easy.

However, I’ve seen some developers (which includes the past me) use CoordinatorLayout as container of some sort, kind of like a FrameLayout. While this “works”, it isn’t optimal.

CoordinatorLayout is computationally more expensive than any other layout in Android, thus including it in your layouts when you’re not using its specific features will unnecessarily increase CPU load in return for no benefit. Thus, if you’re not using any of CoordinatorLayout‘s features, it’s always better to replace with a FrameLayout or a RelativeLayout to lessen the CPU load.

This is a relatively short blog post, but an important one for me as I’ve been unnecessarily using CoordinatorLayouts when using other layouts would have been a better choice.

About the Author Chris Jeon

Software developer currently focusing on Android development.