Can’t form a chain between two views/widgets in Android Studio

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….

Group views in ConstraintLayout to treat them as a single view

ConstraintLayout Chains Android developers recently released a new version of ConstraintLayout (1.0.2 as of today). This version contains a new major feature – Chains, which allows us to group views in ConstraintLayout. Chains provide group-like behavior in a single axis (horizontally or vertically). A set of widgets are considered a chain if they a linked … Read more

ConstraintLayout Chains and Text Ellipsis + Image on the Right

UPDATE JULY 2020: What does constrainedWidth/Height do? A lot of people kept asking me what exactly does this constrainedWidth/Height do when set to true (defaults to false). I finally have an answer (from a Google employee), so in lieu of clearing up all the doubts people coming to this post keep having, here’s what I … Read more

Constraint Layout Vertical Align Center

It’s possible to set the center aligned view as an anchor for other views. In the example below “@+id/stat_2” centered horizontally in parent and it serves as an anchor for other views in this layout. <android.support.constraint.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”match_parent”> <TextView android:id=”@+id/stat_1″ android:layout_width=”80dp” android:layout_height=”wrap_content” android:layout_marginEnd=”8dp” android:gravity=”center” android:maxLines=”1″ android:text=”10″ android:textColor=”#777″ android:textSize=”22sp” app:layout_constraintTop_toTopOf=”@+id/stat_2″ app:layout_constraintEnd_toStartOf=”@+id/divider_1″ /> <TextView android:id=”@+id/stat_detail_1″ … Read more

How to achieve overlap/negative margin on Constraint Layout?

Update ConstraintLayout now supports negative margins with version 2.1.0-alpha2. Simply state android:layout_marginTop=”-25dp” for a negative 25dp margin. (This will only work if the top of the view is constrained. A margin has no effect in ConstraintLayout if the margin’s side is not constrained.) Clarification: The answer below remains valid, but I want to clarify a … Read more

tech