ConstraintLayout ненужная ошибка - PullRequest
0 голосов
/ 03 июля 2018

Я использую ConstraintLayout, обернутый layout тегами для dataBinding, , все макеты работают нормально во время выполнения и во время выполнения , но я получил досадную проблему:

xml screenshot

Как вы видите, идентификатор ограничения говорит: «Не удается разрешить символ '@ + id / tvAccount'», выглядел как ошибки при попытке фиксации, но в рабочем процессе или приложении нет ничего плохого, и все работает нормально, как и предполагалось. Это одинаково во всех XML-файлах. Очистка, аннулирование кэша и т. Д. Не исправляет его. Кто-нибудь встречал такую ​​же проблему?

Edit: В XML-коде для заставки будет указано «Не удается разрешить символ '@ + id / imageViewSplash'» при наведении указателя мыши на app:layout_constraintTop_toBottomOf="@+id/imageViewSplash":

<?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">

    <!--suppress AndroidUnknownAttribute -->
    <data class="SplashBinding"/>

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.splash.SplashFragment">

        <ImageView
            android:id="@+id/imageViewSplash"
            android:layout_width="wrap_content"
            android:layout_height="39dp"
            android:layout_marginBottom="8dp"
            android:contentDescription="@string/content_description_splash_icon"
            android:src="@mipmap/splash_icon"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"/>

        <ImageView
            android:id="@+id/imageViewSplashLoader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="16dp"
            android:contentDescription="@string/content_description_splash_loading"
            android:src="@mipmap/splash_loader"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageViewSplash"/>
    </android.support.constraint.ConstraintLayout>
</layout>

Редактировать 2: Это та же ошибка при наведении на app:layout_constraintTop_toBottomOf="@+id/imageViewSplash", даже без <layout> тегов:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.splash.SplashFragment">

    <ImageView
        android:id="@+id/imageViewSplash"
        android:layout_width="wrap_content"
        android:layout_height="39dp"
        android:layout_marginBottom="8dp"
        android:contentDescription="@string/content_description_splash_icon"
        android:src="@mipmap/splash_icon"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <ImageView
        android:id="@+id/imageViewSplashLoader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="16dp"
        android:contentDescription="@string/content_description_splash_loading"
        android:src="@mipmap/splash_loader"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageViewSplash"/>
</android.support.constraint.ConstraintLayout>

1 Ответ

0 голосов
/ 03 июля 2018

После сохранения макета в редакторе у меня может быть решение для вас. Возможная причина здесь может быть с xmlns:bind и xmlns:android

Пожалуйста, попробуйте после того, как он не показывает мне никакой ошибки.

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:bind="http://schemas.android.com/apk/res/android">

    <data></data>

    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/tvAccount"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="32dp"
            android:layout_marginTop="13dp"
            android:layout_marginEnd="32dp"
            android:text="Account"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/tvPhoneValidationTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="Phone Validation"
            app:layout_constraintEnd_toEndOf="@id/tvAccount"
            app:layout_constraintStart_toStartOf="@id/tvAccount"
            app:layout_constraintTop_toBottomOf="@id/tvAccount" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...