Constraint Layout details

In XML , i have Constraint Layout as Parent.
1 . Any other layout is allowed inside this constraint layout as inner layout (child)
2 . If allowed , Can i give constraints to inner layout

Yes.

Any immediate child of a ConstraintLayout can have constraints. So, suppose you have a layout like:

<ConstraintLayout>
  <LinearLayout>
    <ImageView>
    <ImageView>
  </LinearLayout>
  <TextView />
</ConstraintLayout>

(I am just showing the elements to keep this short)

The LinearLayout and the TextView can (and should) use constraints to size and position them within their ConstraintLayout parent. However, neither ImageView can have constraints, as they are children of a LinearLayout, not a ConstraintLayout.

However, you are welcome to nest ConstraintLayout containers:

<ConstraintLayout>
  <ConstraintLayout>
    <ImageView>
    <ImageView>
  </ConstraintLayout>
  <TextView />
</ConstraintLayout>

Now the ImageView widgets can use constraints to size/position them within the inner ConstraintLayout.

Normally, we do not need inner containers like this when we use ConstraintLayout. One scenario where we do is when the inner container has a different background, directly or provided by something else (e.g., a CardView).

1 Like

Okay Thank you .
I also want to how to know whether some action is performed on a view with in a certain period of time ( eg. Whether a Button is clicked in last 1000ms of time )

Store the start time in a field (e.g., System.currentTimeMillis()). Compare that with the current time when the event occurs.

1 Like

What difference below layout structure can make in performance or in any aspect if i use

Sorry, but I do not understand your question.

What difference i can see if i use following cases in my XML
case 1 : Constraint Layout as Parent and Frame layout, Linear layout as children
case 2 : Linear Layout as Parent and Frame layout, Linear layout as children

I guess I still do not understand the question. ConstraintLayout can do many things that LinearLayout cannot, both on its own (e.g., chains, circular constraints) and in conjunction with helper objects (e.g., Guideline, Barrier). And, as I noted earlier, you do not normally need “Frame layout, Linear layout as children” of a ConstraintLayout, unless you need to provide a background behind some collection of children.

Okay
I’m facing problem when i inflate constraint layout with 3 Buttons in Linear way and there is no problem when i inflate constraint layout with Linear layout for those Buttons
Problem is Button text and Button background are not proper as given

Without the layouts to examine, and without screenshots or something that shows us what exactly “Button text and Button background are not proper as given”, there is very little that we can do to advise you further. A ConstraintLayout, on its own, does not affect the text or background of widgets that are children of the ConstraintLayout.