CardView изменяет размер при добавлении новых элементов - PullRequest
1 голос
/ 28 мая 2020

Я пытаюсь изменить исходный код, который получает новостную ленту из RSS-ссылки и отображает ее в этом линейном макете.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    card_view:cardCornerRadius="10dp"
    android:layout_marginTop="9dp"
    android:layout_marginLeft="9dp"
    android:layout_marginRight="9dp"
    card_view:cardElevation="0.01dp"
    android:layout_marginBottom="0dp"
    card_view:cardPreventCornerOverlap="true"
    card_view:cardUseCompatPadding="true"
    android:id="@+id/cardview">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/date_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_margin="@dimen/activity_horizontal_margin"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <ImageView
            android:id="@+id/thumb_img"
            android:scaleType="centerCrop"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_below="@+id/date_text"
            android:layout_centerHorizontal="true" />

        <TextView
            android:ellipsize="end"
            android:id="@+id/title_text"
            android:adjustViewBounds="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/thumb_img"
            android:layout_centerHorizontal="true"
            android:background="#80000000"
            android:padding="8dp"
            android:gravity="center"
            android:textAppearance="?android:attr/textAppearanceLargeInverse" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Description"
            android:textSize="15dp"
            android:padding="10dp"
            android:fontFamily="@font/g_light"
            android:textColor="#000"
            android:id="@+id/description_text"
            android:layout_below="@+id/thumb_img"
            android:layout_alignRight="@+id/date_text"
            android:layout_alignEnd="@+id/date_text" />
    </RelativeLayout>


</androidx.cardview.widget.CardView>
</LinearLayout>

Пример вывода: normaloutput

Макет представления корзины

<?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout 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:background="@color/colorPrimary"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:showIn="@layout/activity_main">

        <androidx.recyclerview.widget.RecyclerView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/recyclerview"
            />
    </RelativeLayout>

Я хочу добавить несколько источников каналов и отобразить их,

Я объявил publi c stati c ArrayList feedItems;

Для каждого нового источника:

for (int i = 0; i < sources.length; i++) {
            readRss = new ReadRss( this, recyclerView, sources[i]);
            readRss.execute();
        }

поэтому в классе ReadRss я просто добавляю элементы в свой publi c stati c список

feedItems.add(item);

Моя проблема в что мой вид карты меняет размер каждый раз, когда я добавляю новые источники:

Пример вывода моей проблемы: output problem

...