ConstraintLayout Tutorial Part 4 - BARRIERS AND GROUPS - Android Studio Tutorial

Coding in Flow · 71K views · 2018 · 5:42

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when asking about ConstraintLayout barriers, since it shows how to set them up in Android Studio and what to expect from them.

Recommended by 1 people across 1 different months, 2019 to 2020.

What it is

A short Android Studio tutorial from Coding in Flow, part 4 of a ConstraintLayout series, covering features added in ConstraintLayout 1.1.0. It demonstrates constrained width and height, percent-based sizing, barriers (including barrierAllowsGoneWidgets) and groups for toggling visibility of several views at once.

What people said

Recommends me.at.coding · 2020-08 · Stack Overflow · on “How to constrain a View below two Views whose visibility can be switched?”

As proposed by CommonsWare, it can be done with a Barrier as follows: <androidx.constraintlayout.widget.Barrier android:id="@+id/barrier" android:layout_width="wrap_content" android:layout_height="wrap_content" app:barrierDirection="bottom" app:barrierAllowsGoneWidgets="false" app:constraint_referenced_ids="middle1,middle2" /> Note that the IDs in app:constraint_referenced_ids are written without the @id/ prefix. As my middle1 and middle2 have different heights and I set one of them to View.GONE I went with app:barrierAllowsGoneWidgets="false" to make sure that the Barrier position gets updated and no blank space is left over. For more details see the official documentation [LINK] or e.g. on

Cites tjarvstrand · 2019-02 · Stack Overflow · on “ConstraintLayout Barrier not visible in design view”

I'm trying to add a barrier to my ConstraintLayout in Android Studio but it is not showing up the way it should in design view. I have been following this tutorial [this video] , but I can't get things to work properly. I'm currently using: Android Studio 3.1.1 androidx.constraintlayout:constraintlayout:1.1.3 Things I have tried: Invalidate caches/restart Removing the attribute tools:layout_editor_absoluteX Fiddling around! Here's my test.xml : <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android=" [LINK] " xmlns:app=" [LINK] " xmlns:tools=" [LINK] " android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:text="B

Cites MrLem · 2020-06 · Stack Overflow · on “Can't constrain an element to a barrier”

I'm having an issue where I'm trying to constrain a button to a vertical barrier. When I drag the button's side that I want to constrain to the barrier, it doesn't seem to recognise the barrier. It doesn't snap onto it or apply any constraint after hovering onto it and letting go. I've tried replicating a simple tutorial from YouTube, where he constrains his button to the barrier with no issue at the time stamped link: [this video] . I'm aware you can add the barrier ID to the Button's XML's left contraint. But it doesn't exactly fix the underlying issue. I've also checked my version's current changelog on barriers (nothing changed). edit: here's my XML file: <?xml version="1.0" encoding="utf-8"?