Changing height of RecyclerView after animation

I have a DialogFragment with a layout like this:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/logo_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true">

        ...

    </FrameLayout>

    <LinearLayout
        android:id="@+id/search_container"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/logo_container"
        android:layout_above="@+id/create">

        <EditText
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <ViewFlipper
            android:id="@+id/flipper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/found_circles_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal" />

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/list"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1" />

            </LinearLayout>

        </ViewFlipper>

    </LinearLayout>

    <Button
        android:id="@+id/create"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="create" />

    <Button
        android:id="@+id/cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@+id/create"
        android:text="cancel" />

</RelativeLayout>

      

And I need to animate the translation of the RecyclerView and the whole container. I do it like this:

LinearLayout container = (LinearLayout) view.findViewById(R.id.search_container);
... 
int distance = *some calculations*;
container.animate().setDuration(500).yBy(distance).start();

      

So, all the views are animated correctly, but the RecyclerView's height and container remain the same as before the animation. I believe it is measured when the view is created and it maintains that size. But I need this RecyclerView to take all the space from the top of the root view to the create button (positioning at the bottom of the dialog) after animation. How can i do this?

+3


source to share





All Articles