Невозможно использовать авторазмер текста в библиотеке поддержки - PullRequest
0 голосов
/ 05 июня 2018

У меня есть следующее текстовое представление, которое должно содержать текст с автоматическими размерами.

<TextView
    android:layout_width="0dp"
    android:layout_height="200dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toBottomOf="@id/tabRecyclerView"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:background="@color/lightshade"
    android:text="@string/add_favorites_message"
    android:gravity="center"
    android:minLines="2"
    android:maxLines="2"
    app:autoSizeTextType="uniform"/>

Однако я получаю сообщение об ошибке "неожиданный префикс пространства имен" app "" со ссылкой на последнюю строку.

Я нахожу это странным, потому что я использую следующие библиотеки поддержки в моем build.gradle:

implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'

Я использую эту документацию в качестве руководства.

Что я делаю не так?

Вот полный макет:

<?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="250dp"
    tools:context=".MainActivity">


    <android.support.v7.widget.RecyclerView
        android:id="@+id/tabRecyclerView"
        android:layout_width="0dp"
        android:layout_height="50dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toTopOf="@id/imageRecyclerView"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/imageRecyclerView"
        android:layout_width="0dp"
        android:layout_height="200dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tabRecyclerView"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:background="@color/lightshade"
        />

    <TextView
        android:id="@+id/add_favorites_message"
        android:layout_width="0dp"
        android:layout_height="200dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tabRecyclerView"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:background="@color/lightshade"
        android:text="@string/add_favorites_message"
        android:visibility="gone"
        android:gravity="center"
        android:minLines="2"
        android:maxLines="2" />


</android.support.constraint.ConstraintLayout>

1 Ответ

0 голосов
/ 05 июня 2018

Мне пришлось изменить TextView на:

<android.support.v7.widget.AppCompatTextView
    android:id="@+id/add_favorites_message"
    android:layout_width="0dp"
    android:layout_height="200dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toBottomOf="@id/tabRecyclerView"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:autoSizeTextType="uniform"
    android:background="@color/lightshade"
    android:text="@string/add_favorites_message"
    android:visibility="gone"
    android:gravity="center"
    android:lines="2"
    />

Этот ответ не имеет смысла для меня, потому что первый ответ в этом сообщении говорит, что я не должендолжен сделать это.Но по крайней мере ошибка ушла.

...