Почему я не могу использовать атрибуты ConstaintLayout - PullRequest
0 голосов
/ 28 августа 2018

Итак, я пытаюсь использовать ConstraintLayout в первый раз. И я не могу использовать атрибуты ConstraintLayout, такие как app:layout_constraintBottom_toBottomOf, чтобы позиционировать своих детей.

Код не компилируется, когда я пытаюсь использовать атрибуты. Он скомпилируется, если я использую ConstraintLayout, но ни один из его атрибутов. Что я должен сделать, чтобы получить доступ к этим атрибутам?

Я получаю ошибку сборки:

error: not well-formed (invalid token).
Message{kind=ERROR, text=error: not well-formed (invalid token)., sources= 
[C:\AndroidWorkSource\SalesRabbit-Android\Universal- 
Sales\app\src\main\res\layout\fragment_routeitem_list.xml:48], original 
message=, tool name=Optional.of(AAPT)}

Здесь приведен XML-макет:

<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"
    android:orientation="vertical"
    android:background="@color/white">

    . . . . 

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_routs_list"
        android:name="com.salesrabbit.android.sales.universal.canvass.routeing.MyRouteFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        app:layoutManager="LinearLayoutManager"
        tools:context=".canvass.routeing.MyRouteFragment"
        tools:listitem="@layout/fragment_routeitem"
        android:layout_below="@id/my_routes_divider"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        app:layout_constraintBottom_toBottomOf ="id/my_routs_list"
        android:gravity="center"
        android:orientation="horizontal">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="?android:attr/buttonBarButtonStyle"
            android:drawableLeft="@drawable/caret"
            android:text="@string/my_routs_new_route"
            android:background="@color/white"
            android:layout_gravity="center_horizontal"
            />
    </LinearLayout>



</android.support.constraint.ConstraintLayout>

В файле сборки у меня есть это:

dependencies { 
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    . . . . .

1 Ответ

0 голосов
/ 28 августа 2018

В строке

app:layout_constraintBottom_toBottomOf ="id/my_routs_list"

у вас есть странный символ пробела, который называется HAIR SPACE (U+200A) перед =, из-за которого XML-файл искажен. Удаление и добавление @ перед идентификатором должно решить вашу проблему:

app:layout_constraintBottom_toBottomOf="@id/my_routs_list"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...