0
votes

I am developing an android app and I am used to relative/linear layout but now I decided to use ConstraintLayout. I am a novice in ConstraintLayout. I was reading some documents online and I have also read an official android document on ConstraintLayout.

ConstraintLayout give us a linear and flat view for our layout.

I have few doubts/questions in mind which I didn't found in the official document:

  1. Can we use RelativeLayout or LinearLayout inside ConstraintLayout? Is it standard practice or not?
  2. If yes, then does it create a multi-layer inside ConstraintLayout?
  3. If no, then how should we manage some small UI components in ConstraintLayout? because I have one design which requires to combine two/three view and need some separate background. we can achieve easily this with RelativeLayout or LinearLayout?

Could anyone please help me to understand ConstraintLayout.

2

2 Answers

2
votes
  1. Can we use RelativeLayout or LinearLayout inside ConstraintLayout? Is it standard practice or not?

No. You should not. You should read Optimizing Layout Hierarchies and Performance and view hierarchies

  1. If yes, then does it create a multi-layer inside ConstraintLayout?

Same as above. [yes it creates multi layer]

  1. If no, then how should we manage some small UI components in ConstraintLayout? because I have one design which requires to combine two/three view and need some separate background. we can achieve easily this with RelativeLayout or LinearLayout?

There are ways to do almost everything using ConstraintLayout. As being a novice of this Layout, you may be frustrated when you face difficulty to create a few complex designs. But after some time you will forget to use even RelativeLayout :). Read the link provide by Rajnish in the comment and ConstraintLayout. There are several videos you may find to learn.

1
votes

It is not considered best-practice to use RelativeLayout/LinearLayout inside ConstraintLayout but ConstraintLayout has many "Widgets" to help you design your screens

This is a great source to understand the different "Widgets"