Questions tagged [constraint-layout-chains]
67 questions
158
votes
13 answers
How to achieve overlap/negative margin on Constraint Layout?
Is it possible to achieve negative margin on constraint layout to achieve overlap?
I am trying to have a image centered on the layout and have a Text view such that it overlaps a by x dp. I tried setting negative margin value but no luck.
It would…

bond
- 11,236
- 7
- 48
- 62
124
votes
8 answers
Constraint Layout Vertical Align Center
How to vertically align and center objects in constraint layout? It is possible to align vertically or horizontally but I have not found a way to center at the same time beside constraining the views between two gridlines.
Vertical Align…

Ray Li
- 7,601
- 6
- 25
- 41
56
votes
5 answers
ConstraintLayout Chains and Text Ellipsis + Image on the Right
UPDATE JULY 2020:
Added information in the answer below to explain in more detail why/what does constrainedWidth/Height do and when it's applicable to use them.
UPDATE JULY 2018:
If you are using ConstraintLayout 1.1.0, the correct property to use…

Martin Marconcini
- 26,875
- 19
- 106
- 144
52
votes
4 answers
Group views in ConstraintLayout to treat them as a single view
I need to apply some constraints to a group of views in ConstraintLayout. I want to group these views and continue editing while the layout designer in Android studio treats them as a single view. Is there a way to do so without actually wrapping…

Yury Fedorov
- 14,508
- 6
- 50
- 66
42
votes
16 answers
Can't form a chain between two views/widgets in Android Studio
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…

C.Kraz
- 483
- 1
- 4
- 10
33
votes
3 answers
ConstraintLayout doesn't respect max height
I'm trying to create a layout composition using ConstraintLayout.
In order to simplify my case, my layout should have three parts:
The first layout (in red), that should grow according to the remaining space and has a max height.
The second layout…

Rom Shiri
- 1,390
- 4
- 16
- 29
23
votes
2 answers
androidx.constraintlayout.widget.constraintlayout don't have chains that you can drag
I'm using androidx.constraintlayout.widget.ConstraintLayout in my layout and it does not show the chains, also I can't drag any widgets. I just type the constraints that I want to use.

raquezha
- 283
- 1
- 2
- 13
12
votes
1 answer
Spread-chain group of elements with ConstraintLayout
I'm having an issue to spread-chain 2 groups of elements with Constraint Layout. I understand the goal of this new layout is to use a flat hierarchy so I'd like to avoid putting my elements inside a child layouts.
I looked at some awesome resources…

Antoine
- 583
- 2
- 6
- 21
10
votes
3 answers
ConstraintLayout GONE view occupies space
I have a ViewHolder with the header on top and that header becomes visible in a specific case. In most other cases, the header is set as GONE. The problem is that when a header is set as GONE, its height is still calculated and other views are…

bajicdusko
- 1,630
- 1
- 17
- 32
9
votes
1 answer
Align views right in ConstraintLayout without clipping
I am creating a dialog with two buttons aligned right in relation to the parent ConstraintLayout.
Everything is fine, until the text of the buttons becomes very long. When the text of either or both buttons is lengthy, the buttons extend beyond the…

VIN
- 6,385
- 7
- 38
- 77
8
votes
2 answers
How to place two views center horizontal in ConstraintLayout?
In ConstraintLayout I need to assume two views as a group and place this group center horizontal in the parent like the below image:
This is my xml code:

Alireza Noorali
- 3,129
- 2
- 33
- 80
8
votes
1 answer
Cycle Chain Mode button not show after create chain
I'm using Android Studio 3.4.1.
When i work with ConstraintLayout, i dragged 3 buttons into the layout, select all, and create horizontal chain. But Cycle Chain Mode button not showing after that. So, i can not select other options: Packed, Spread,…

Ton
- 113
- 5
8
votes
1 answer
Android constraint layout divide in horizontal
I'm working with an Android project and I used ConstraintLayout.
I want to design the layout as two blocks which stay in horizontal line. Each block will get 50% of the width:
How can I do this with ConstraintLayout?

Sheikh Hasib
- 7,423
- 2
- 25
- 37
8
votes
2 answers
ConstraintLayout chain with fixed aspect ratio
I'm trying to build an activity with 3 imageViews according to the following layout:
<------W-------> <------W-------->
^ +---------------+--------+---------------+
| | | | |
| | | …

dvkch
- 1,079
- 1
- 12
- 20
8
votes
4 answers
ConstraintLayout chain does not work if some chained views constrained to another chained view
I am not sure whether it is a bug of ConstraintLayout or not, so I try to ask if somebody knows I made any mistake.
I have a layout which I want to spread evenly on the screen 3 elements.
Just like below:
I formed horizontal chains between them and…

Sira Lam
- 5,179
- 3
- 34
- 68