Is the ConstraintLayout the new standard? - android

My question is about the ConstraintLayout because since Android Studio 2.3, when I want to create a new Layout, the default Layout in my xml file is the ConstraintLayout.
Is the ConstraintLayout the new standard ?
What about the others layouts (LinearLayout, GridLayout, RelativeLayout,...) ? Will they be depreciated ? Do I have to Convert all my layout using the converting tool ?
What is the best practice? Use as much as possible the ConstraintLayout ?
This is a bit confusing because I don't like to use the visual editor and it's a quite difficult to do ConstraintLayout using the code editor.

when I want to create a new Layout, the default Layout in my xml file is the ConstraintLayout
Whether or not a ConstraintLayout is created depends entirely on what templates you are using.
Is the ConstraintLayout the new standard ?
It is what many of the Android Studio 2.3 templates use. Those templates are merely examples used a starting point by some developers. Those templates differ on older versions of Android Studio and most likely will change again in the future.
What about the others layouts (LinearLayout, GridLayout, RelativeLayout,...) ? Will they be depreciated ?
That is very unlikely.
Do I have to Convert all my layout using the converting tool ?
No.
What is the best practice? Use as much as possible the ConstraintLayout ?
Use what works for you. Consider ConstraintLayout as a candidate, but do not feel obligated to use it. In particular places where you determine that layout performance is critical (e.g., scrolling lists), if you determine that your existing approach is not performing well, consider testing ConstraintLayout to see if it helps (it may or it may not). Also note that ConstraintLayout itself does not handle all scenarios — for example, I have yet to see a working means of implementing a TableLayout structure (with automatic column sizing) using a ConstraintLayout.

Related

What is the benefit of having RelativeLayout after the introduction of ConstraintLayout?

I totally understand the advantage of having ConstraintLayout when flatenning nested UI's. But with the introduction of ConstraintLayout I see people adopting it instead of RelativeLayout even for simple layouts with a flat structure.
Does ConstraintLayout always performs better than RelativeLayout?
Specifically in the case when a view can be achieved with single flat
structure with no nested UI?
If yes, shouldn't Relative Layout be deprecated?
Any help would be much appreciated :)
I think that should be a matter of choice and customs. Some UI designers prefer RelativeLayout where others prefer ConstraintLayout. The ConstraintLayout can be used in many cases more than the RelativeLayout. And yes it performs better than the RelativeLayout but I think for just a single flat structure I can opt for RelativeLayout too though due to support tooling provided by the ConstraintLayout it makes it a better option if you need that feature.
That's my point of view.
Yes, it performs better, ConstraintLayout has designed with performance optimization in mind. Also, it's very straightforward to use by just drag and drop things.
I really like Constraint layout to develop complex layout faster than any other one, but in my opinion, it's harder to make changes on it when you need, but is just my point of view
Q1 - Does ConstraintLayout always performs better than RelativeLayout
A1 - I saw a lot of questions and answers on StackOverflow about that subject and here is what I can say base on those threads and my personal experience with ConstraintLayout :
In most cases, if you are using ConstraintLayout properly it will work faster but , there is no guaranty that this is what you will get all the time.
From my personal experience with ConstraintLayout, it is working really fast and in all of my layouts (both simple and complicated in terms of UI) it works faster than RelativeLayout.
Q2 - shouldn't Relative Layout be deprecated
A2 - Why I believe that Relative Layout should not be deprecated.
I honestly don't see any valid reason for RelativeLayout to be deprecated, altho I am using ConstaintLayout I first started with RelativeLayout and now I see it as another tool to build my UI.
If it's not broken don't fix it:
Don't forget that there are a lot of developers around the globe, some prefer
RelativeLayout and some prefer ConstraintLayout, let's keep it this way is what I believe - don't take the option to choose from the developers, give them the option to choose what to use.
ConstraintLayout is not a better solution for building UI as a fact, its just my opinion.
I really think that its something that depends on the developer and his decisions, therefore - no layout is better than the other and no layout should be deprecated (as long as it works)

Why android studio automatically reorders views and elements in graphical layout editor

I was curious about knowing that why this happens in android studio when I'm trying to graphically edit layouts. Every views and attributes are reorganised. is there any rendering benefits or any benefits at all?
Because its not a drag and drop editor. Not really. You're putting children into a parent layout, which works on certain rules. When you drag children around, you change the rules but you're never putting it in a particular place.
I really, really, really suggest you don't use the graphical layout editor. Its confusing, not very accurate (especially if using custom views) and inefficient. Learn how to write layout xml, you'll be much faster and write easier to maintain layouts. Most pro devs don't use it at all.

Android XML Layout or Java Coded

I am starting to delve into Android Development and there is a lot of material online. The question is... What are the pro's and con's against the drag and drop XML design method vs coding the view manually? The only reason I ask on here is because online the views are mixed and they don't really back up what they're defending.
If I use the drag and drop method will I have issues further onto my development adventures? That is the thing that worries me the most... I don't want to learn the drag and drop method and then editting the XML to cater for my needs and then be handicapped by it.
For the beginner(s), I highly recommend not to use Drag and drop. We need to understand XML, to be comfortable with android widget. Understanding XML will come handy in future when creating custom styles and themes.
Here are few pointers before you dive in android XML layout
Try sticking with match_parent and wrap_content while defining android:layout_height or android:layout_width if possible
Make sure you have good understanding of RelativeLayout, LinearLayout and FrameLayout and how its child views are arranged.
Forget about ConstraintLayout, AppbarLayout and similar advance layout at current.
Try exploring TextView, EditText, Button, ImageView and ProressBar as far as possible.(This are most common widgets/views)
Try avoiding any tutorial related to ListView, its deprecated. Try using RecyclerView instead, it is one of the important widget that would be used in regular basis.

Why go for Constraints layout as we already have Relative Layout? [duplicate]

This question already has answers here:
Differences between ConstraintLayout and RelativeLayout
(10 answers)
Closed 6 years ago.
Why RelativeLayout replaced to ConstraintLayout in the default layout file of an android empty activity. I need to know why we should use ConstraintLayout, what other benefits it provides to us.
As provided by Xaver Kapeller - "The main purpose of the ConstraintLayout is to fix problems with the RelativeLayout, and it does it so well. You can do so many things that were impossible with a RelativeLayout. And you can simplify your layout like you never could before. Additionally, it fixes a long-standing performance issue of the RelativeLayout. The double taxation during the measure/layout phase. So we get better performance, more versatility and much simpler layouts in one nice package."
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 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.
However, the Constraint Layout was designed to be used in Studio and
it can efficiently express your app design so that you rely on fewer
layouts like LinearLayout, FrameLayout, TableLayout, or GridLayout.
Lastly, with the built-in automatic constraints inference engine. You
can freely design your UI to your liking and let Android Studio do the
hard work.

Android GUI Layouts in Eclipse

I am very new to Android development and am having some trouble. I am creating an XML file using Eclipse, both the Graphical Layout feature is what I'm having trouble with.
Also, I am working in Android 2.3 for compatibility reasons.
I am wondering if there is a layout which enables me to place buttons or text fields or any attribute where I want to put them. This may sound stupid, but it seems that every layout has some sort of order in which it lets you add attributes, and whenever I try to drag them elsewhere on the layout things just get very very messy.
If what you want is an AbsoluteLayout, this has been deprecated since Android 2 (IIRC). You can try using the RelativeLayout, which let you position freely your widgets. Else, if you only use LinearLayout, then yes the widget will be positioned in a strict way.
use Relative Layout. I recommend that you read up on Android layouts so you understand why, what and hows of Android way. There are some good tutorials that I found helpful. TutsPlus: Android Layouts
There is also a very good video from Marakana.
Marakana: Android Bootcamp
If you are just starting out with Android check other tutorials/videos on Marakana. They are a very good resource for beginners.

Categories

Resources