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
42
votes
2 answers

No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package

I am using the Android SDK 2.2.3. I am following a book on programming Android. The code is:
41
votes
4 answers

Nested Constraint Layout? is it a bad practice or not?

I have a gray area in understanding the use of Constraint Layout. I have implemented my layout with Constraint Layout. But It happens that I want to make a group of the view items to act as one view, for example making two ImageViews and a TextView…
Akram
  • 2,158
  • 1
  • 17
  • 24
41
votes
4 answers

make RecyclerView's height to "wrap_content" in Constraint layout

i'm trying to set the height of recycler view on wrap_content and make it respect that,but it will exceed the other widget on layout. what can i do now?
Ali Samawi
  • 1,079
  • 1
  • 9
  • 18
39
votes
2 answers

Android - Constraint layout - How to align a view centered over edge of other view?

I want to build a layout like this: Inside the constraint layout there is an Image View which acts like a banner, then there is a Card that is center aligned with the bottom edge of the banner and then there is another Image View that is center…
Suhas Shelar
  • 963
  • 2
  • 10
  • 23
38
votes
2 answers

Is it advisable to use LinearLayout inside ConstraintLayout in Android?

I am new to ConstraintLayout in Android and newbie to Android too. I have a question. Is it advisable to use LinearLayout inside ConstraintLayout? For example:
TechBee
  • 1,897
  • 4
  • 22
  • 46
38
votes
5 answers

Android RecyclerView in ConstraintLayout doesn't scroll

I have a recyclerView inside a constraint layout and I cannot make it scroll, the list just continues below the screen without scroll possibility. If I turn the layout into relative layout the scroll works fine. how can I get it to scroll? the the…
37
votes
5 answers

Programmatically set margin to ConstraintLayout

I need to change margin of toolbar, which was made of ConstraintLayout, in different cases. I tried to do it in following way ConstraintLayout.LayoutParams newLayoutParams = new…
Asset Bekbossynov
  • 1,633
  • 3
  • 13
  • 25
35
votes
4 answers

how to MODIFY a constraint layout programmatically?

Ive got a view like below :
Amir Ziarati
  • 14,248
  • 11
  • 47
  • 52
35
votes
1 answer

Restrict width in ConstraintLayout by another view

Is there a possibility (in ConstraintLayout) to let a view grow only as long as there is space for another view at his right? The use case is to have a value and unit TextViews besides each other. The value TextView should be able to grow as long as…
mbo
  • 4,611
  • 2
  • 34
  • 54
35
votes
5 answers

ConstraintLayout: set height of all views in row to match the tallest one

I'm trying to utilize a ConstraintLayout (version 1.0.2) to set the height of 2 side-by-side views to match the tallest one of them. This serves as a ViewHolder in for a RecyclerView, where each TextView gets an arbitrary length of text... If I set…
jazzgil
  • 2,250
  • 2
  • 19
  • 20
35
votes
1 answer
35
votes
1 answer

Why go for Constraints layout as we already have Relative Layout?

Why RelativeLayout replaced to ConstraintLayout in the default layout file of an android empty activity. I need to know why we should use ConstraintLayout, what other benefits it provides to us.
34
votes
1 answer

Cannot set visibility on individual items in a ConstraintLayout.Group

I have a ConstraintLayout.Group defined like this:
Michał Klimczak
  • 12,674
  • 8
  • 66
  • 99
34
votes
3 answers

How to make View fill remaining space in ConstraintsLayout

How to make View FrameLayout fill all remaining space in ConstraintLayout I have xml like:
34
votes
8 answers

marginTop does not work with ConstraintLayout and wrap_content

In my Fragment I have a ConstraintLayout with layout_height="wrap_content" and I would like to have a margin between my two buttons at the bottom of the view. When I add this margin as layout_marginBottom to the upper button (button_welcome_signup)…