TextView отображается в AndroidStudio, но не на устройстве

Я знаю, что об этом уже спрашивали, но решение из этого сообщения не сработало для меня.

Я только начинаю изучать программирование под Android и делал макет. Он правильно отображается в Android Studio, но не на моем устройстве. Изображения и цвет фона отображаются правильно, но текст не отображается. Я пробовал изменить шрифт и fontColor. Что нужно изменить?

У меня был еще один пример, который использовал ReleativeLayout, и он отображается правильно, но этот ConstraintLayout - нет.

Первое изображение - от AS, второе - с моего устройства.

TextView отображается в AndroidStudio, но не на устройстве

TextView отображается в AndroidStudio, но не на устройстве

Это код из activity_main

<?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:id = "@+id/listLayout"
    android:layout_width = "wrap_content"
    android:layout_height = "248dp"
    android:layout_marginEnd = "4dp"
    android:layout_marginStart = "4dp"
    android:layout_marginTop = "4dp"
    tools:context = "com.vijer.test1.MainActivity">
    <!-- First Group -->
    <View
        android:id = "@+id/group_one"
        android:layout_width = "match_parent"
        android:layout_height = "80dp"
        android:background = "@android:color/darker_gray"
        app:layout_constraintLeft_creator = "@id/listLayout"
        app:layout_constraintTop_creator = "@id/listLayout" />

    <ImageView
        android:id = "@+id/album_art1"
        android:layout_width = "80dp"
        android:layout_height = "80dp"
        android:contentDescription = "@string/image_description"
        android:src = "@drawable/image1"
        app:layout_constraintLeft_creator = "@id/listLayout"
        app:layout_constraintTop_toTopOf = "@id/listLayout" />

    <View
        android:layout_width = "match_parent"
        android:layout_height = "match_parent"
        app:layout_constraintEnd_toEndOf = "parent" />

    <TextView
        android:id = "@+id/meta_artist1"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "18sp"
        android:textStyle = "bold"
        app:layout_constraintLeft_toRightOf = "@id/album_art1"
        app:layout_constraintTop_toTopOf = "@id/listLayout"
        tools:text = "@string/tag_artist1" />

    <TextView
        android:id = "@+id/meta_title1"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "18sp"
        android:textStyle = "bold"
        app:layout_constraintLeft_toRightOf = "@id/album_art1"
        app:layout_constraintTop_toBottomOf = "@id/meta_artist1"
        tools:text = "@string/tag_title1" />

    <TextView
        android:id = "@+id/meta_album1"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintLeft_toRightOf = "@id/album_art1"
        app:layout_constraintTop_toBottomOf = "@id/meta_title1"
        tools:text = "@string/tag_album1" />

    <TextView
        android:id = "@+id/meta_time1"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginStart = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintEnd_toStartOf = "@+id/meta_delimiter1"
        app:layout_constraintTop_toBottomOf = "@id/meta_title1"
        tools:text = "@string/tag_length1" />

    <TextView
        android:id = "@+id/meta_delimiter1"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginStart = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintEnd_toStartOf = "@+id/meta_file_type1"
        app:layout_constraintTop_toBottomOf = "@id/meta_title1"
        tools:text = "@string/tag_delimiter" />

    <TextView
        android:id = "@+id/meta_file_type1"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginTop = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintBottom_toBottomOf = "@+id/meta_time1"
        app:layout_constraintEnd_toEndOf = "@+id/listLayout"
        tools:text = "@string/tag_file_type1" />

    <!-- Second Group -->

    <View
        android:id = "@+id/group_two"
        android:layout_width = "match_parent"
        android:layout_height = "80dp"
        android:layout_marginTop = "4dp"
        android:background = "@android:color/darker_gray"
        app:layout_constraintLeft_toLeftOf = "@id/listLayout"
        app:layout_constraintTop_toBottomOf = "@id/group_one"
        tools:layout_editor_absoluteX = "0dp" />

    <ImageView
        android:id = "@+id/album_art2"
        android:layout_width = "80dp"
        android:layout_height = "80dp"
        android:layout_marginTop = "4dp"
        android:contentDescription = "@string/image_description"
        android:src = "@drawable/image2"
        app:layout_constraintLeft_toLeftOf = "@id/listLayout"
        app:layout_constraintTop_toBottomOf = "@id/group_one" />

    <View
        android:layout_width = "match_parent"
        android:layout_height = "match_parent"
        app:layout_constraintEnd_toEndOf = "parent" />

    <TextView
        android:id = "@+id/meta_artist12"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginTop = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "18sp"
        android:textStyle = "bold"
        app:layout_constraintLeft_toRightOf = "@id/album_art2"
        app:layout_constraintTop_toBottomOf = "@id/group_one"
        tools:text = "@string/tag_artist2" />

    <TextView
        android:id = "@+id/meta_title12"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "30dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "18sp"
        android:textStyle = "bold"
        app:layout_constraintLeft_toRightOf = "@id/album_art2"
        app:layout_constraintTop_toBottomOf = "@id/group_one"
        tools:text = "@string/tag_title2" />

    <TextView
        android:id = "@+id/meta_album12"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintLeft_toRightOf = "@id/album_art2"
        app:layout_constraintTop_toBottomOf = "@id/group_one"
        tools:text = "@string/tag_album2" />

    <TextView
        android:id = "@+id/meta_time12"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintEnd_toStartOf = "@+id/meta_delimiter12"
        app:layout_constraintTop_toBottomOf = "@id/group_one"
        tools:text = "@string/tag_length2" />

    <TextView
        android:id = "@+id/meta_delimiter12"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintEnd_toStartOf = "@+id/meta_file_type12"
        app:layout_constraintTop_toBottomOf = "@id/group_one"
        tools:text = "@string/tag_delimiter" />

    <TextView
        android:id = "@+id/meta_file_type12"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"

        app:layout_constraintBottom_toBottomOf = "@+id/meta_time12"
        app:layout_constraintEnd_toEndOf = "@+id/group_one"
        tools:text = "@string/tag_file_type2" />

    <!-- Third Group -->
    <View
        android:id = "@+id/group_three"
        android:layout_width = "match_parent"
        android:layout_height = "80dp"
        android:layout_marginTop = "4dp"
        android:background = "@android:color/darker_gray"
        app:layout_constraintLeft_toLeftOf = "@id/listLayout"
        app:layout_constraintTop_toBottomOf = "@id/group_two" />

    <ImageView
        android:id = "@+id/album_art3"
        android:layout_width = "80dp"
        android:layout_height = "80dp"
        android:layout_marginTop = "4dp"
        android:contentDescription = "@string/image_description"
        android:src = "@drawable/image3"
        app:layout_constraintLeft_toLeftOf = "@id/listLayout"
        app:layout_constraintTop_toBottomOf = "@id/group_two" />

    <View
        android:layout_width = "match_parent"
        android:layout_height = "match_parent"
        app:layout_constraintEnd_toEndOf = "parent" />

    <TextView
        android:id = "@+id/meta_artist13"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "4dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "18sp"
        android:textStyle = "bold"
        app:layout_constraintLeft_toRightOf = "@id/album_art3"
        app:layout_constraintTop_toBottomOf = "@id/group_two"
        tools:text = "@string/tag_artist3" />

    <TextView
        android:id = "@+id/meta_title13"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "30dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "18sp"
        android:textStyle = "bold"
        app:layout_constraintLeft_toRightOf = "@id/album_art3"
        app:layout_constraintTop_toBottomOf = "@id/group_two"
        tools:text = "@string/tag_title3" />

    <TextView
        android:id = "@+id/meta_album13"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintLeft_toRightOf = "@id/album_art3"
        app:layout_constraintTop_toBottomOf = "@id/group_two"
        tools:text = "@string/tag_album3" />

    <TextView
        android:id = "@+id/meta_time13"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintEnd_toStartOf = "@+id/meta_delimiter13"
        app:layout_constraintTop_toBottomOf = "@id/group_two"
        tools:text = "@string/tag_length3" />

    <TextView
        android:id = "@+id/meta_delimiter13"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginStart = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintEnd_toStartOf = "@+id/meta_file_type13"
        app:layout_constraintTop_toBottomOf = "@id/group_two"
        tools:text = "@string/tag_delimiter" />

    <TextView
        android:id = "@+id/meta_file_type13"
        android:layout_width = "match_parent"
        android:layout_height = "wrap_content"
        android:layout_marginEnd = "4dp"
        android:layout_marginTop = "56dp"
        android:fontFamily = "@font/abeezee"
        android:textColor = "#ffffff"
        android:textSize = "16sp"
        app:layout_constraintBottom_toBottomOf = "@+id/meta_time13"
        app:layout_constraintEnd_toEndOf = "@+id/group_two"
        tools:text = "@string/tag_file_type3" />

</android.support.constraint.ConstraintLayout>
1
0
46
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Ответ принят как подходящий

Использовать

андроид: text = "@ string / tag_artist1"

Вместо того

инструменты: text = "@ string / tag_artist1"

То же самое во всех текстовых представлениях. инструменты используется для отображения текста только в режиме разработчика. Это помогает в тестировании элемента пользовательского интерфейса при создании xml

Хорошо знать. Я вижу эти инструменты: текст автоматически добавляется Android Studio, когда вы перетаскиваете TextView на экран дизайна.

Vijer 12.09.2018 08:07

Вы использовали текстовые представления с атрибутом инструменты: текст. Это будет отображать текст только в дизайне вашей студии Android, но не на устройстве.

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

Прочтите ниже статью об инструментах и ​​их использовании. https://android.jlelse.eu/tools-attributes-hidden-gems-of-android-studio-d7451b194e0b

Другие вопросы по теме