When I'm using the layout editor in Android Studio and I try to make a chain (bidirectional constraint) between a EditText View and a Button View using the constraint anchors, it doesn't make the chain.
It only makes a constraint if I try to constrain one View to the other.
I am trying to chain the right side of the EditText to the left side of the Button.
This is what my Layout Editor looks like:
Chains in XMLOn textView there is app:layout_constraintEndToStartOf="@+id/textView2" ; and on textView2 there is app:layout_constraintStart_toEndOf="@+id/textView" - essentially creating two constraints between the same pair of anchor points in opposite directions. It is this which defines a chain.
Creating a chain is really easy, we can click and drag to select views or press ctrl and select views from Component Tree. And then right click on selected views in Editor Or Component Tree to apply constraints. You can see that in action in following screen records.
I was trying to figure this out too. I've discovered that one way to do it is to select both views, then right click and select Center Horizontally. This creates the chain, but then you have to adjust any other constraints accordingly. I'm new to Android, so I'm sure there will be other ways....
I had the same issue. Solved it by going in into the XML as instructed by the tutorial: https://developer.android.com/training/basics/firstapp/building-ui.html
On the tutorial, click "See the final layout XML" and compare. My XML was missing:
app:layout_constraintLeft_toRightOf="@+id/editText"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With