Android Studio Recyclerview (горизонтальный) - убрать анимацию при выходе из вида - PullRequest
0 голосов
/ 14 апреля 2020

Я создал простой вид переработчика в линейном макете. Когда я прокручиваю вправо, я хочу, чтобы элементы исчезли за моим frameLayout. (Это должно выглядеть так, как будто вы больше не видите элементы, потому что они находятся за frameLayout).

К сожалению, отображаемые элементы движутся за невидимой стеной (левая граница окна рециркуляции), а не за моим frameLayout. Есть ли способ удалить анимацию для предметов, оставляющих переработчик?

Спасибо за любую помощь!

Код:

  <androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="300dp"
    android:layout_marginTop="10dp"
    android:orientation="horizontal">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_exerciseCards"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:animateLayoutChanges="false"
        android:paddingLeft="40dp"

        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:layout_width="50dp"
            android:layout_height="300dp"
            android:layout_marginLeft="-10dp"
            android:background="@drawable/view_newexercise_deck"
            android:elevation="4dp" />

        <com.example.projecttraining0.VerticalTextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="-5dp"
            android:elevation="4dp"
            android:rotation="180"

            android:text="My Exercises"
            android:textAlignment="center"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="18sp" />
    </FrameLayout>

снимок экрана

1 Ответ

0 голосов
/ 15 апреля 2020

Используя LinearLayout, FrameLayout и RecyclerView размещаются рядом друг с другом без наложения. Если вы хотите, чтобы ваш RecyclerView был на всю ширину, вы можете использовать ConstraintLayout вместо родительского LinearLayout.

Вы можете ограничить свой RecyclerView родительским, чтобы он занимал весь экран. А также поместите RecyclerView первым в иерархии, а FrameLayout - вторым, чтобы FrameLayout находился сверху и перекрывал RecyclerView.

Вы можете многое узнать о ConstraintLayout здесь . На YouTube также много видеоуроков.

...