约束布局无法在Android Studio中呈现

时间:2018-02-06 13:10:51

标签: android android-layout android-studio android-constraintlayout

编码约束布局:

<View
    android:id="@+id/divider"
    style="@style/divider_style"
    android:layout_width="0dp"
    swedbank:layout_constraintBottom_toBottomOf="parent"
    swedbank:layout_constraintLeft_toLeftOf="parent" />

<ImageView
    android:id="@+id/some_image"
    style="@style/some_style"
    swedbank:layout_constraintBottom_toBottomOf="@+id/divider" <!-- This '+' -->
    swedbank:layout_constraintRight_toRightOf="parent"
    swedbank:layout_constraintTop_toTopOf="@+id/divider" />   <!-- This '+' -->

请参阅注释:这些行上的加号必须在那里才能使android studio布局渲染器工作。没有他们你会得到:

Couldn't resolve resource @id/divider   Tip: Try to refresh the layout.

我一直认为@+id/是您第一次定义ID?

如果我几年前在任何地方使用+#es,我会遇到IDE问题:使用goto-definition,IDE将无法知道要转到哪个ID

在Android studio 2.3.3和3.0.1上测试

看到自动完成会给你带来各地,我应该选择那个吗?

1 个答案:

答案 0 :(得分:0)

尝试将此添加到gradle中的依赖项部分 compile 'com.android.support.constraint:constraint-layout:1.0.2'