I have a gray area in understanding the use of Constraint Layout
.
I have implemented my layout with Constraint Layout
. But It happens that I want to make a group of the view items to act as one view, for example making two ImageView
s and a TextView
to respond to click like a single view so I need to put them in another layout and use this layout to respond to click.
I am wondering is it alright to put them in another Constraint Layout
( other layouts can not give the arrangement of views that I want to have) which will led to having nested Constraint Layout
in a single layout.
So generally is it alright to have nested Constraint Layout
or it will be a wrong practice regarding the purpose of it (i.e. having flat layout)?
Edit
As in answers there are suggestions for setting listener for each of these views instead of setting it for their parent layout, I have already tested this approach and it is not what I need. An example is when I have a customized button with text and a drawable (which I can't make it with drawableLeft
or drawableRight
attributes of a button itself because it won't look like what we had in design). So as you see I can't make ImageView
and TextView
listen to the click individually because user will see two different click effect and it won't look like a single button click.