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?
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!
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.
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.
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...
“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.
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 Textview
s respectively, you can use LinearLayout. ConstraintLayout needs more XML code than LinearLayout for simple structures, and using LinearLayout is better for these situations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With