1

I have the following text view, which is supposed to contain auto sizing text.

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

However, I am getting the error "unexpected namespace prefix "app"" in reference to the last line.

I find this odd because I am using the following support libraries in my 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'

I'm using this documentation as my guide.

What am I doing wrong?

Here is the full 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="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>
Roymunson
  • 5,099
  • 10
  • 48
  • 106

1 Answers1

1

I had to change the TextView to:

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

This answer doesn't make sense to me because the first answer in this post, says I shouldn't have to do this. But at least the error is gone.

Roymunson
  • 5,099
  • 10
  • 48
  • 106