Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Constraint Layout Barriers Missing In Context Menu of Android Android Studio

I am currently going through a ConstraintLayout tutorial and stuck in a specific step (https://codelabs.developers.google.com/codelabs/constraint-layout/#10).

The source is here (https://github.com/googlecodelabs/constraint-layout).

Per instructions below, it says to add a vertical barrier but I do not see the add option in the menu. Actually the entire menu options look different. Where is the "Add Vertical barrier" menu?

Right click on ConstraintLayout in the blueprint or the Component Tree. You will see the Add Vertical barrier and Add Horizontal barrier options.

I am running Android 2.3.3.

build.gradle (Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.google.googleio"
        minSdkVersion 22
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
}

enter image description here

like image 224
ethan Avatar asked Sep 03 '17 22:09

ethan


People also ask

How can we solve missing constraints in constraint layout?

Constraint errors Without constraints, the objects in your app would likely jump out of position when the app is loaded or the device is rotated. To automatically apply any missing constraints you can press the 'Infer Constraints' button at the top of the editor.

How do you set a barrier in constraint layout?

Creating Barriers in XMLThe app:barrierDirection attribute determines the direction of the Barrier - in this case it will be positioned at the end of the referenced Views. The list of referenced Views is a comma separated list of the IDs of other Views within the layout (without the @+id/ qualifier).

What is a constraint layout in Android Studio?

A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread).

What is Androidx ConstraintLayout widget barrier?

androidx.constraintlayout.widget.Barrier. Added in 1.1. A Barrier references multiple widgets as input, and creates a virtual guideline based on the most extreme widget on the specified side. For example, a left barrier will align to the left of all the referenced views.


2 Answers

I am running Android 2.3.3.

I am going to guess that you mean that you are running Android Studio 2.3.3. In that case, there is no such menu. That is added in Android Studio 3.0, available in beta from today.

like image 143
CommonsWare Avatar answered Sep 19 '22 11:09

CommonsWare


Add this line to your gradle (Module:app)

implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'

like image 25
Jose Avatar answered Sep 22 '22 11:09

Jose