我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="profile"
type="android.arch.lifecycle.MutableLiveData<myapp.UserProfileDetails>"/>
</data>
<ScrollView
android:id="@+id/scrollViewProfileContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".UserProfileEditActivity">
<ImageView
android:id="@+id/imageViewProfileAvatar"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:scaleType="fitXY"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/com_facebook_profile_picture_blank_square"/>
<TextView
android:id="@+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:text="@{profile.name + ' ' + profile.lastName}"
android:textAlignment="viewStart"
android:ellipsize="end"
android:maxLines="2"
android:textAppearance="@android:style/TextAppearance.Material.Display1"
app:layout_constraintBottom_toBottomOf="@+id/imageViewProfileAvatar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageViewProfileAvatar"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:text="@string/label_profile_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageViewProfileAvatar"/>
<EditText
android:id="@+id/editText3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:inputType="textPersonName"
android:text="@={profile.name}"
android:maxLength="15"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView11"/>
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/label_profile_last_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText3"/>
<EditText
android:id="@+id/editText5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:inputType="textPersonName"
android:text="@={profile.lastName}"
android:maxLength="30"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView12"/>
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/label_profile_phone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText5"/>
<EditText
android:id="@+id/editText6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:maxLength="32"
android:inputType="phone"
android:text="@={profile.phone}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView13"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</layout>
出什么问题了?每个属性(例如app:layout_constraintBottom_toBottomOf="@+id/imageViewProfileAvatar"
)在源视图中都以红色突出显示,例如:
无法解析符号'“ @ + id / imageViewProfileAvatar'
上述所有app:layout_constrait ...属性也是如此。但是,设计器似乎还不错,代码可以编译,并且应用程序可以正常工作。
这是在更新到Android Studio 3.2之后开始的。你有什么主意吗?真烦人。我试过了:重建应用程序,使缓存无效,重新同步到gradle,没有任何帮助。
约束布局在build.gradle中添加如下:
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
答案 0 :(得分:0)
将关注依赖项添加到(app / build.gradle)
实现'com.android.support.constraint:constraint-layout:1.1.3'