Med Besbes
Med Besbes

Reputation: 2021

ViewFlipper with just one view

I have a ViewFlipper that contains a LinearLayout which contains some TextViews.

When I go to the previous or next item (TextViews get updated with other values), I want the ViewFlipper to get a full animation. For example fade_in, fade_out.

For example:

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

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="320dp"
        android:layout_height="435dp"
        android:background="@drawable/ic_launcher"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Flipper Content 1" >
        </TextView>
    </LinearLayout>
</ViewFlipper> 

When I click on next TextView01, I want to change its value to Flipper Content 2 with a full animation. For example, Flipper Content 1 gets out to the left then Flipper Content 2 comes in from the right.

Upvotes: 0

Views: 612

Answers (1)

Marko Lazić
Marko Lazić

Reputation: 883

If I understood your question properly. In the part where you create your screen you should acquire your ViewFlipper object and set InAnimation and OutAnimation

    ViewFlipper viewFlipper01 = (ViewFlipper)findViewById(R.id.ViewFlipper01);
    viewFlipper01.setInAnimation(AnimationUtils.loadAnimation(this.getActivity(), android.R.anim.fade_in));
    viewFlipper01.setOutAnimation(AnimationUtils.loadAnimation(this.getActivity(), android.R.anim.fade_out));

Hope this helps and enjoy your work.

Upvotes: 2

Related Questions