Отображение изображения в recyclerView + Picasso

Без заглушки .placeholder(R.drawable.nedostupno) отображается список, содержащий ID и название изображения, а также другая информация в текстовом виде. Но из-за ошибки 504 не отображаются изображения.

Было решено добавить заглушку на случай ошибки. Но после добавления заглушки и error() теперь отображается только заглушка, а другие данные и текст пропадают.

Как сделать так, чтобы отображалась и заглушка и данные из других текст представлений?

Picasso.get().setLoggingEnabled(true)
    Picasso.get().load(full_img_url)
        .fit()
        .placeholder(R.drawable.nedostupno)
        .error(R.drawable.nedostupno)
        .into(holder.tvPoster)
        <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:paddingTop="6dp"
    android:paddingBottom="8dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <ImageView
        android:id="@+id/poster"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        app:srcCompat="@mipmap/ic_launcher_round"
        android:contentDescription="@string/todo" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tvTitle"
            android:layout_width="wrap_content"
            android:textColor="@android:color/black"
            android:layout_height="wrap_content"
            android:text="@string/tvTitle" />

        <TextView
            android:id="@+id/tvimdb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/black"
            android:text="@string/tvimdbID" />

        <TextView
            android:id="@+id/tvType"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/black"
            android:text="@string/tvType" />

        <TextView
            android:id="@+id/tvYear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/black"
            android:text="@string/tvYear" />
    </LinearLayout>


</LinearLayout>

Ответы (1 шт):

Автор решения: Alex_Skvortsov

Для корректной работы необходимо выполнить два действия:

  1. Исправить ширину вложенного LinearLayout, заменив android:layout_width="match_parent"

на android:layout_width="wrap_content". В противном случае, вложенный LinearLayout полностью занимает своего родителя, игнорируя другие элементы. (аналогично с android:layout_height для вертикальных LinearLayout).

  1. Жестко задать ширину картинке, чтобы она не пыталась занять произвольный объем, то есть заменить android:layout_width="wrap_content" на android:layout_width="100dp". Картинка теперь станет одинаковой по высоте и ширине.

Авторство второй части ответа принадлежит @ЮрийСПб♦

→ Ссылка