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'
}
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.
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).
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).
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.
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.
Add this line to your gradle (Module:app)
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With