1

我有三个视图(A、B 和 C),它们相互堆叠。因此,当我单击一个按钮时,两个视图(B 和 C)从视图 A 后面动画并向下滚动到底部。现在我的动画工作正常,但视图 B 和 C 延伸到屏幕外,我的屏幕高度没有增加。这是我的 layout.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:animateLayoutChanges="true">

    <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:id="@+id/trips_menu_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorBackgroundGrey">

        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:id="@+id/layout_id_1"
            android:layout_margin="8dp"
            card_view:contentPadding="8dp"
            card_view:cardElevation="16dp">

        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:id="@+id/layout_id_2"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="40dp"
            card_view:contentPadding="8dp"
            card_view:cardElevation="2dp">

        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:id="@+id/layout_id_3"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="40dp"
            card_view:contentPadding="8dp"
            android:visibility="invisible">

        </android.support.v7.widget.CardView>

    </RelativeLayout>

</ScrollView>

而我的动画是简单的平移Y动画。

关于如何在两个视图动画到底部时增加布局高度的任何建议?

4

0 回答 0