"Расширяй больше" с анимацией

Я пытаюсь сделать ту же анимацию, что и Google: https://vid.me/9Wli

Краткое описание моего приложения:

Вверху у меня есть панель приложений, под ней - LinearLayout, включающая кнопку для расширения дополнительной информации, а под этой линией LinearLayout - RecyclerView.

На данный момент, когда я нажимаю кнопку "развернуть больше", я просто показываю некоторые элементы с.setVisibility(View.VISIBLE), поэтому у меня нет анимации.

Вот мой фактический код XML:

<LinearLayout
    android:id="@+id/expandable_zone"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:visibility="gone">

    <LinearLayout
        android:id="@+id/1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_width="wrap_content"
            android:text="@string/expandable_1"
            android:textColor="@color/secondaryTextDark"
            android:textSize="13dp" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottom_expandable_zone"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:orientation="vertical">

        <TextView
            android:animateLayoutChanges="true"
            android:id="@+id/expand_more"
            android:layout_gravity="center_horizontal"
            android:layout_height="wrap_content"
            android:layout_marginBottom="11sp"
            android:layout_marginTop="11sp"
            android:layout_width="wrap_content"
            android:text="@string/expand_more"
            android:textColor="@color/secondaryTextDark" />

        <ImageButton
            android:background="@drawable/circle_shape"
            android:id="@+id/expand_less"
            android:layout_gravity="center_horizontal"
            android:layout_height="wrap_content"
            android:layout_marginBottom="11sp"
            android:layout_marginTop="10sp"
            android:layout_width="wrap_content"
            android:src="@drawable/ic_check_grey600_24dp"
            android:visibility="gone" />
    </LinearLayout>
</LinearLayout>

Кто-нибудь может дать мне лучшее решение для этого?

1 ответ

android:animateLayoutChanges="true"
установить его на LinearLayout android:id="@+id/bottom_expandable_zone"

если это не поможет, вам нужно найти на stackru, как анимировать представление и реализовать его на вашем android:id="@+id/bottom_expandable_zone"

Другие вопросы по тегам