Анимировать предметы из переработчика, когда вид внутри предметов меняется - PullRequest
0 голосов
/ 02 мая 2020

Ниже приведена компоновка для одного из моих предметов в форме ресивера. Я хочу анимировать, когда я скрываю или показываю description представление. Итак, я установил animatelayoutChanges="true" на itemView и включил переход в моем адаптере, используя ((ViewGroup)((RecordViewHolder)viewHolder).itemView).getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);

<LinearLayout 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/itemView"
android:animateLayoutChanges="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
    android:id="@+id/daily_record_show"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:animateLayoutChanges="true"
    android:layout_height="wrap_content">
    <LinearLayout
        android:id="@+id/daily_record_show_inner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="5dp"
        android:paddingBottom="5dp">

        <TextView
            android:id="@+id/dateView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingRight="5dp"
            android:text="12-03-2018"
            android:visibility="gone" />

        <TextView
            android:id="@+id/name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="60"
            android:drawablePadding="10dp"
            android:text="@string/carried_forward"
            android:textAlignment="textStart"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp"
            android:visibility="visible" />

        <TextView
            android:id="@+id/amt"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="40"
            android:paddingEnd="20dp"
            android:singleLine="true"
            android:text="100"
            android:textAlignment="textEnd"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp" />
    </LinearLayout>
    <TextView
        android:id="@+id/description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="8dp"
        android:text="@string/backup_to_google_drive_text"
        android:textSize="14sp"
        android:textStyle="italic"
        android:visibility="gone" />

</LinearLayout>
<LinearLayout> some other views ...</LinearLayout>

Макет анимируется, как и ожидалось, для 5 элементов. Над 5 предметами предметы анимируются без необходимости. Кроме того, элементы показывают дополнительные пробелы при прокрутке.

Мне нужно несколько советов о том, как сделать так, чтобы анимация работала плавно для любого количества элементов и убрать эти ненужные места при прокрутке.

...