The awesomeness of Constraint Layout

The awesomeness of Constraint Layout

Recently I started creating layouts using XML in android studio. I view other developer's XML code and wonder why they use constraint layout, whereas I was only introduced to relative and linear layout while I was learning layouts in XML. The question that keeps ringing in my brain is, why do I have to use constraint layout again at this point? Is there any difference? Of course, there is a huge difference and one is always most preferred to all.

So, if you have ever wondered like me what features does constraint layout has over other layouts, then this article is for you. Here, I will share two important reasons you need to start using constraints layout in next your project.

DIFFERENT PHONE SCREEN SIZE

You'll most definitely want your app to work on different screen sizes, therefore you need to position your app widgets dynamically to perform suitable scaling types and re-adjusting the UI to different screen sizes. It may be difficult to achieve this using other layouts, but can be achieved using constraint layout with the help of some features like;

app:layout_constraintStart_toStartOf=" "

app:layout_constraintTop_toTopOf=" "

app:layout_constraintEnd_toEndOf=" "

app:layout_constraintBottom_toBottomOf=" "

FOR COMPLEX VIEWS

We understand that constraint layout in android gives you adaptable and flexible ways when creating views for your apps. With constraint layout, we can also design complex layouts using the GUI of the layout editor by just dragging and dropping UI elements into the visual code editor instead of writing layout XML code.

Conclusion

This article is only meant for the newbie that finds it difficult to understand why they need to use constraint layout in their project. I hope you now know the power of constraint layout.

If you enjoyed this article, kindly like and share it with friends, colleagues. More so, follow me on Twitter so as not to miss my latest articles. Thanks for reading