Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I always use ConstraintLayout for everything?

just a simple question, should we always use Constraint Layout for everything? why another layout still used today?

I want to make a simple login layout like this, should I use Linear Layout or Constraint Layout?

enter image description here

usually, I make every layout with Constraint Layout but my friend told me to use Linear Layout for the login, is it wrong if I use Constraint Layout? thanks before!

like image 235
prs_wjy Avatar asked Nov 09 '19 07:11

prs_wjy


People also ask

What is constraintlayout and how to use it?

This one is what makes ConstraintLayout that powerful. You can position elements relatively with each other (just like in RelativeLayout). Constraints could be either another view or directly the parent. Let’s see it in action. With the help of these constraint properties, you can align elements the way you like without having nested layouts.

What is constraint layout in Android?

Constraint Layout: This new layout is a flexible layout manager for your app that allows you to create dynamic user interfaces without nesting multiple layouts. It is distributed as a support library that is tightly coupled with Android Studio and backwards compatible to API Level 9. At first glance, Constraint Layout is similar to RelativeLayout.

What are the benefits of using relativelayout?

An additional benefit of using it is that it allows you to create your layouts using a drag and drop style editor visually in a way RelativeLayout couldn't similar to Interface Builder in Xcode. Constraint Layout: This new layout is a flexible layout manager for your app that allows you to create dynamic user interfaces without nesting...

What is “gone margin” in constraintlayout?

“Gone Margin” is introduced with ConstraintLayout to solve this issue. Imagine that you have a hierarchy as shown above. You want to make A’s visibility GONE. When A is GONE, B will automatically slide to A’s position. In order to prevent that you can give gone_margin to the related direction.


1 Answers

ConstraintLayout helps you to avoid using nested layouts and it causes better performance. it's not wrong to use it for everything but if you know that you are not going to have nested layouts, for example, three Textviews respectively, you can use LinearLayout. ConstraintLayout needs more XML code than LinearLayout for simple structures, and using LinearLayout is better for these situations.

like image 177
houman.sanati Avatar answered Oct 10 '22 04:10

houman.sanati