Recyclerview: ImageView в CardView соответствует центру и скрывает другие текстовые просмотры перед прокруткой - PullRequest
0 голосов
/ 20 ноября 2018

Я пытаюсь представить CardView с 3-мя текстовыми изображениями и imageView внутри RecyclerView. Проблема заключается в том, что если перед началом прокрутки imageView полностью заполнено в просмотре карты, а текстовые просмотры скрыты, даже если предполагается, что относительное расположение внутри просмотра карточки будет держать изображение на левой стороне. После прокрутки некоторые просмотры карт в конечном итоге будут выглядеть так, как я хочу, если я отсортирую Список и обновлю адаптер, то все просмотры карт, кроме последней, будут такими, как я хочу.

Вот соответствующие XML: Cardview:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:padding="4dp">
    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cv"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="1dp"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/cv_photo"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_marginEnd="1dp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/cv_name"
                android:layout_toEndOf="@+id/cv_photo"
                android:layout_alignParentTop="true"
                android:textSize="14sp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/cv_number"
                android:layout_toEndOf="@+id/cv_photo"
                android:layout_below="@+id/cv_name"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/cv_date"
                android:layout_toEndOf="@+id/cv_photo"
                android:layout_below="@+id/cv_number"
                />
        </RelativeLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

RecyclerView:

<android.support.v7.widget.RecyclerView
        android:id="@+id/ProfileRecycler"
        android:layout_width="368dp"
        android:layout_height="491dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_below="@+id/viewbox"
        android:clipToPadding="false"

        />

Код адаптера (есть все необходимое)

@Override
    public ProfileViewHolder onCreateViewHolder(ViewGroup viewGroup, int i){
        View view = LayoutInflater.from(segruppe.getContext()).inflate(R.layout.profileview,viewGroup,false);
        ProfileViewHolder holder = new ProfileViewHolder(view);
        return holder;

    }
    @Override
    public void onBindViewHolder(ProfileViewHolder ProfileViewHolder,int i){
        profileViewHolder.name.setText(profiles.get(i).getName());
        profileViewHolder.number.setText(String.valueOf(profiles.get(i).getNumber()));
        profileViewHolder.dato.setText(profiles.get(i).getDate().toString());
        if(profiles.get(i).getImage()!=null)
        Glide.with(context).load(profiles.get(i).getImage()).into(profileViewHolder.image);
    }

Фрагмент кода для создания переработчика карт:

profileRecycler = getView().findViewById(R.id.ProfileRecycler);
profileAdapter = new ProfileAdapter(getContext(),profileList);
GridLayoutManager glm = new GridLayoutManager(getActivity(),4, LinearLayoutManager.HORIZONTAL,false);
profileRecycler.setLayoutManager(glm);
profileRecycler.setAdapter(profileAdapter);

Кто-нибудь может увидеть, что здесь происходит не так? (Стоит упомянуть, что если в просмотре карт нет изображения imageView, оно остается полностью статичным во время и после прокрутки, как и должно быть)

...