8

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?
Community
  • 1
  • 1
Shima Erfan
  • 335
  • 1
  • 5
  • 19

2 Answers2

6
  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).
Nicolas Roard
  • 8,339
  • 1
  • 28
  • 30
3

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

Tom Wayne
  • 1,288
  • 1
  • 12
  • 31
  • What about nested ConstraintLayout? – capt.swag Dec 12 '17 at 15:58
  • Well, nesting in general makes the performance worse. It not a good idea to create some nested constraint layouts which hold for example just two Textviews or something like that. Thanks to flexibility of constraint layout (many cool thinks are added in Constrain layout 1.1 - check it out) you can do more flat view hierarchies inside constraint layout, which allows you to get the rid of many nested layout and get you some extra performance. – Tom Wayne Dec 13 '17 at 17:13