Questions tagged [android-constraintlayout]

A new type of layout available in the Android Support repository built on top of a flexible constraint system, marking views positions relative to each other.

ConstraintLayout is new type of layout that you can use in your android app. It is new powerful and flexible Android layout that allows you to express complex UI without nesting multiple layouts.

It is available since Android Studio 2.2, part of the support library and compatible from API level 9 (Android 2.3 GINGERBREAD).

ConstraintLayout aims at improving performance of layouts by reducing layout hierarchies and reduce the complexity of trying to work with RelativeLayout.

ConstraintLayout is compatible with other layout types such as RecyclerView, LinearLayout.

There are currently various types of constraints that you can use:

Relative positioning Margins Centering positioning Circular positioning Visibility behavior Dimension constraints Chains Virtual Helpers objects Optimizer

For more information about ConstraintLayout - Build a Responsive UI with ConstraintLayout

3207 questions
25
votes
1 answer

Programmatically change height in constraint layout?

I have a simple layout: a fixed height TextView with three ImageView objects anchored to the bottom of the view. How can I programmatically change the height of each of the ImageViews so they vary within some range (10dp, 16dp below the TextView)?…
rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123
25
votes
5 answers

android ConstraintLayout does not allow negative margins

I position lots of items relative to a layout guide, and would like to position a new item nearly relative to this layout guide. I tried with a negative layout margin without success.
Softlion
  • 12,281
  • 11
  • 58
  • 88
24
votes
1 answer

Two Buttons with equal width in Constraint Layout

How can I get two buttons side by side in ConstraintLayout with fixed and equal length? Something like this:
bhavya_karia
  • 760
  • 1
  • 6
  • 12
24
votes
4 answers

View.GONE does not work on "Constraint.Group" specific children

I'm experimenting with "Constraint.Group" and I've children views: A, B, C. In code, "Constraint.Group".visibility = View.Gone does work, but if I choose to do A.visibility = View.Gone it does not take an effect on children view. Is this normal…
MaaAn13
  • 264
  • 5
  • 24
  • 54
24
votes
4 answers

ConstraintLayout - proportional width/height to self?

I'm trying to figure out how to achieve the following behaviour using constraint layout: Place a view in the center of the ConstraintLayout parent Make the view width to be half of the parent's width Make the view height equals to its width (i.e -…
dor506
  • 5,246
  • 9
  • 44
  • 79
24
votes
6 answers

How to half overlap images in android constraint layout

Is there any way to place an images half is on top of another image using only constraint layout. I know it can be done using relative and frame layouts but in the case of constraint layout is there anyway? prefer ways which do not require any…
24
votes
3 answers

How to use ViewStub in ConstraintLayout?

It seems that when inflating a ViewStub in a ConstraintLayout, the resulting view has lost all its constraints. I guess we can define the constraints for the inflated view using ConstraintSet, but that kind of defeats the purpose of ViewStub. Is…
joharei
  • 578
  • 1
  • 5
  • 22
24
votes
1 answer

goneMargin is not respected in a wrap_content ConstraintLayout?

I have a ConstraintLayout where its height is wrap_content. I want its height to be able to collapse or expanding, according to its Child's height. Simple and common enough, right? Now I have a layout which looks like this: (First of all, please…
Sira Lam
  • 5,179
  • 3
  • 34
  • 68
24
votes
4 answers

How to use new features in constraint layout 1.1?

Does anyone know how to use new features in constraint layout 1.1, namely barriers and percent-based dimensions? There is absolutely no documentation available online, and the recent Google I/O talk on designer tools covered in detail only…
Roman
  • 243
  • 1
  • 3
  • 5
24
votes
4 answers

Trying to replicate GridLayout column alignment with ConstraintLayout

I'm new to ConstraintLayout, and I'm trying to replicate the same grid behavior offered by GridLayout with ConstraintLayout. Specifically, I want to design a two columns grid. The first column width should be as narrow as possible, while the second…
24
votes
1 answer

Displaying ConstraintLayout in a DialogFragment

I hope you can help me out with a problem. I tried to google it, and looked through the topics here, but was unable to find an answer. I recently changed my layouts to ConstraintLayouts, and this have been working great so far. My problem however is…
24
votes
4 answers

Window Soft Input Mode ConstraintLayout

Earlier there was no problem with soft input mode, but after including ConstraintLayout, content of fragment doesn't move up when the keyboard appears. Manifest
Scrobot
  • 1,911
  • 3
  • 19
  • 36
23
votes
4 answers

How to specify margins for Barrier in Constraintlayout

I am unsure about the best way to specify margins in ConstraintLayout around a Barrier. I tried setting them in the barrier element, but this has no effect and I also couldn't find any documentation on that. …
Display name
  • 2,697
  • 2
  • 31
  • 49
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.
23
votes
1 answer

Single LinearLayout vs Single ConstraintLayout

If I have just a single LinearLayout with a few items in it, then what effects will be of replacing it with ConstraintLayout vs
n.arrow001
  • 1,090
  • 3
  • 10
  • 28