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
34
votes
3 answers

percentage margin with constraintlayout?

I'm learning how to use ConstraintLayout and have found a few good tutorials to have views width and height in percentage. I know I can probably add an empty view to 'create' margin, but it doesn't seem right. Is there a way to things like…
user1865027
  • 3,505
  • 6
  • 33
  • 71
34
votes
9 answers

RecyclerView in ConstraintLayout overlapping other elements

I'm doing a simple list activity with the following components: an EditText, a RecyclerView, a ProgressBar and a Textview. Everything works really well, except for the RecyclerView which overlaps the EditText and goes "beyond" the screen bottom so…
34
votes
3 answers

toggle visibility of chain group in constraint layout

In previous xml layout, I have multiple view groups with few elements inside. Hide each view group will also hide all of its child elements. Since I wanted to have flat structure and tried ConstraintLayout. Cool I know how to chain element with…
Tixeon
  • 930
  • 1
  • 12
  • 27
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
33
votes
10 answers

How to use the new Android Constraint Layout to reduce View hierarchy

Do you have any idea on how to use the new Constraint Layout that was recently announced at this year's Google I/O?
32
votes
1 answer

ConstraintLayout Flow helper example

I have read in a blog entry that in ConstraintLayout 2.0.0, a way was introduced to create a flow of views. What I exactly want to achieve: I have several TextViews with a fixed size next to each other. Depending on screen size, some TextViews…
BenjyTec
  • 1,719
  • 2
  • 12
  • 22
32
votes
14 answers

How to overlay a view in a constraintlayout?

I have this layout of my login activity. I want to overlay progressBar as like it can be done using FrameLayout. How to do this using ConstraintLayout?
Ajay S
  • 48,003
  • 27
  • 91
  • 111
30
votes
7 answers

Constraint layout Layout Crashing : All Children of constraint layout should have ids to use constraint set

After updating to com.android.support.constraint:constraint-layout:1.1.0 The constraint layout crashes saying: All children of constraint layout should have ids to use constraint set I have set ids to all views even then it's…
Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
30
votes
8 answers

How to create accessible focus groups in ConstraintLayout?

Imagine you have a LinearLayout inside a RelativeLayout that contains 3 TextViews with artist, song and album:
hamena314
  • 2,969
  • 5
  • 30
  • 57
28
votes
2 answers

Crash when using ConstraintLayout in Notification

I get an InflationException when I use a ConstraintLayout in a custom Notification. I can use them elsewhere in my app, just not in a custom layout for a Notification. I'm assuming that any widget contained in a support library simply can't be used…
Sky Kelsey
  • 19,192
  • 5
  • 36
  • 77
28
votes
3 answers

ConstraintLayout - centering views with next to each other vertically or horizontally

How to center align 3 buttons with next to each other vertically using ConstraintLayout? To be clear, i want to convert this simple layout structure into flat UI using ConstraintLayout
Darish
  • 11,032
  • 5
  • 50
  • 70
27
votes
8 answers

error inflating ConstraintLayout in android studio

I'm having problems with Android Studio. I recently upgraded my SDK Manager to include; compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' classpath is classpath 'com.android.tools.build:gradle:2.2.3' Project builds fine.…
ausgeorge
  • 975
  • 1
  • 12
  • 23
26
votes
4 answers

ConstraintLayout layout_constraintDimensionRatio not working

I used constraintLayout and layout_constraintDimensionRatio="1:1" (width is wrap_content, height is 0dp (match_constraint)) As a result, I expected width and height to be 1:1, but it's not working. What is wrong? I attached code and…
pistolcaffe
  • 849
  • 1
  • 8
  • 15
25
votes
1 answer

Align FrameLayout inside ConstraintLayout to bottom

I want a layout above recycler view at the bottom of the screen,(like a frame) so that even when that layout is visible I can still scroll recycler view behind it. So I want to align the frame layout at the bottom of the screen and make it visible…
Pritish
  • 1,284
  • 1
  • 19
  • 42
25
votes
4 answers

Set aspect ratio programmatically for imageView

I have a problem with showing a landscape image without centerCrop. I tried PercentFramelayout, and set aspect ratio programmatically like this: laParams.percentLayoutInfo.aspectRatio = img.width.toFloat() / img.height.toFloat() The result is ok…