Android view flipper. Slide views up and out in code (no xml)

13 Views Asked by At

I have a view flipper with two or more views.

When I showNext() I want to slide the current view out of the top of the flipper, and the new view in from the bottom.

When I showPrevious() I want to slide the current view out of the bottom and bring the previous view from the top.

However I need to be able to do this WITHOUT needing to use XML animation files.

<ViewFlipper
    android:id="@+id/lay_flip"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

    <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/black"
            android:text="hello"/>


    </LinearLayout>


    <LinearLayout
        android:id="@+id/lay_compose_message"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/green_dark"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            android:text="hello"/>


    </LinearLayout>

</ViewFlipper>

How can I apply animations to do what I need in code?

0

There are 0 best solutions below