android - 添加 Android Studio 3.0 的布局编辑器工具栏和上下文菜单中缺少的(垂直/水平)障碍

标签 android android-studio android-constraintlayout

我指的是在 https://developer.android.com/training/constraint-layout/index.html#constrain-to-a-barrier 上使用约束布局的指南亲 body 验 Barriers。

步骤说,

To create a barrier, follow these steps:

Click Guidelines in the toolbar, and then click Add Vertical Barrier or Add >Horizontal Barrier.

而当我点击 Guidelines 图标时,它只显示两个选项,即

  1. 添加垂直引用线
  2. 添加水平引用线

即使上下文菜单也不显示添加 Barrier 的选项。


已经有相同上下文的问题Add Constratint Layout Barriers Missing In Context Menu of Android Android Studio但对于由 CommonsWare 回答的 Android Studio 2.3.3。

通过评论与 CommonsWare 进行了讨论,他建议使用 ConstraintLayout 1.1 的测试版

但根据 training guide对于使用 ConstraintLayout,constraintLayout 版本是 1.0.2

dependencies { compile 'com.android.support.constraint:constraint-layout:1.0.2' }

甚至 Android Studio 3.0 release notes表示现在支持创建障碍选项(添加组除外,它需要 ConstraintLayout 1.1.0 beta 2 或更高版本)。

screenshot of Android Studio 3.0 release notes

环境细节:

Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 8.1 6.3

Constraint Layout :1.0.2
Graddle wrapper : gradle-4.1
buildToolsVersion : 26.0.2

最佳答案

根据 this documentation ConstraintLayout 的 1.1.0-beta1 版中引入了障碍。 (重点是我的)

Bugfixes related to wrap_content

New features: barriers, placeholder, percent dimensions

由于屏障是在 1.1.0-beta1 中引入的,因此您不会在任何早期版本中看到它们。

我目前正在运行带有 ConstraintLayout 1.1.0-beta3 的 Android Studio 3.0.1,这是我在设计器中按下指南按钮时看到的:

enter image description here

上下文菜单还将障碍显示为一个选项。

因此,简而言之,您需要 Android Studio 3.0+ 和 ConstraintLayout 版本 1.1.0-beta1 或更高版本才能看到这些选项。

关于android - 添加 Android Studio 3.0 的布局编辑器工具栏和上下文菜单中缺少的(垂直/水平)障碍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47596214/

相关文章:

android - Dispatchers.IO协程线程

android - AppCompat v7 工具栏 "Error inflating class <unknown>"

git - CreateProcess error = 2,系统找不到指定的文件错误

android - 有没有办法在 android studio 中找到所有的 Log.d() 行

java - Android Studio Gradle 未构建示例应用程序

android - 约束布局问题

Android ORMLite - ForeignCollection 子项具有空的外部字段

java - 日历返回错误的当前日期android

android - 如何在android constraintLayout中设置 View 的最大宽度?

android - ConstraintLayout 组与层