Home » Android » android – Constraint Layout instead of Relative Layout

android – Constraint Layout instead of Relative Layout

Posted by: admin June 15, 2020 Leave a comment


In new Android Studio 2.2 the Constraint Layout is introduced, I had searched and read about this new layout here and here. and in this link I had read about differences between Constraint and Relative layouts, but still some questions remain:

  1. Can we replace RelativeLayout with ConstraintLayout completly, as mentioned here?
  2. Do devices with old versions can support ConstraintLayout?
  3. For designing apps with ConstraintLayout we have to update to Android Studio 2.2?
  4. with using ConstraintLayout we don’t need to write many dimens.xml for all screen resolution to have a responsive app?
How to&Answers:
  1. ConstraintLayout does all that RelativeLayout does, and more
  2. It’s supported starting from API level 9 (Gingerbread) — ie. 99.9% of devices
  3. Yes. You can edit the XML by hand too, but the editor in 2.2 is recommended
  4. It depends what you want to do — using dimens might still be useful (for example, you might want roughly the same layout, but with different margins).


The another fact good to know is that ConstraintLayout provides much better performance than RelativeLayout. Especially nested RelativeLayouts can make your performance worse.