Questions tagged [constraint-layout-chains]

62 questions
144
votes
12 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
  • 10,356
  • 6
  • 44
  • 60
105
votes
7 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
  • 5,637
  • 5
  • 19
  • 33
47
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…
44
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…
42
votes
15 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…
29
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,262
  • 4
  • 16
  • 27
20
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.
9
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…
9
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,570
  • 1
  • 15
  • 29
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--------> ^ +---------------+--------+---------------+ | | | | | | | | …
7
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
  • 103
  • 5
7
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…
6
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…
6
votes
5 answers

Constraint Layout not visible on the Layout file...And getting the error while inflating any view on it

I am using the constraint layout (android.support.constraint.ConstraintLayout) as the main layout in my XML file. As we get the two View of layout(One is for User View And Second is for the drag and drop the view and provide the relation between…
5
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:
1
2 3 4 5