Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:42:18+00:00 2026-06-04T20:42:18+00:00

I’ve been trying to implement ViewFlipper and its translate animation. There are many pages

  • 0

I’ve been trying to implement ViewFlipper and its translate animation. There are many pages I can refer to, but no matter how much I tried, I can’t see outAnimation ever happen. Below is my project, and currently no translate animation is seen but IF I COMMENT OUT the vf.setOutAnimation… part, inAnimation animation suddenly starts to work. …why?

package com.example.testview;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.widget.ViewFlipper;

public class TestViewActivity extends Activity implements OnTouchListener {

    private ViewFlipper vf;
    private float firstTouchX;
    private float leaveTouchX;

@Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    vf = (ViewFlipper) findViewById(R.id.viewFlipper1);
    vf.setOnTouchListener(this);
}

    public boolean onTouch(View v, MotionEvent event) {

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                    firstTouchX = event.getX();
                    break;

            case MotionEvent.ACTION_UP:
                    leaveTouchX = event.getX();

                if (this.firstTouchX - 50f > leaveTouchX) {

                    vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.right_in));
                    vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.left_out));
                    vf.showNext();
                }
                if (this.firstTouchX + 50f < leaveTouchX) {

                    vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.left_in));
                    vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.right_out));
                    vf.showPrevious();
                }
                break;
        }
        return true;
    }
}

res/anim/left_in.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="350" 
    android:fromXDelta="-100%p" 
    android:toXDelta="0%p"  
    android:fromYDelta="0%p"
    android:toYDelta="0%p">
</translate>

res/anim/left_out.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="350"
    android:fromXDelta="0%p"
    android:toXDelta="-100%p"
    android:fromYDelta="0%p"
    android:toYDelta="0%p">
</translate>

res/anim/right_in.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="350"
    android:fromXDelta="100%p"
    android:toXDelta="0%p"
    android:fromYDelta="0%p"
    android:toYDelta="0%p">
</translate>

res/anim/right_out.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="350"
    android:fromXDelta="0%p"
    android:toXDelta="100%p"
    android:fromYDelta="0%p"
    android:toYDelta="0%p">
</translate>

res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
    <ViewFlipper
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/viewFlipper1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

         <include
            android:id="@+id/first"
            layout="@layout/first" />

        <include
            android:id="@+id/second"
            layout="@layout/second" />

        <include
            android:id="@+id/third"
            layout="@layout/third" />

    </ViewFlipper>

first.xml / second.xml / third.xml (only their own picture id is different)

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/img">
</ImageView>

BIG EDIT: I just build a smaller project based on my post and it seems to work… perhaps through the process of omitting some codes that I thought unnecessary to start a discussion caused my problem…. I’m really sorry if anybody made an attempt to answer. I’ll do a more survey and hope I can post breakdowns that can be of use for later references, unless mods delete this question.

BIG EDIT2: Today I tried once again, and it DIDN’T WORK, presumably because I used Android ARM 2.2 Emulator. Once I switch into ARM/Inter 2.3.3, it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:42:20+00:00Added an answer on June 4, 2026 at 8:42 pm

    Try this, replace outAnimation into inAnimation like,

                if (this.firstTouchX - 50f > leaveTouchX) {
    
                    vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.left_out));
                    vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.right_in));
                    vf.showNext();
                }
                if (this.firstTouchX + 50f < leaveTouchX) {
    
                    vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.right_out));
                    vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.left_in));
                    vf.showPrevious();
                }
                break;
    

    And then try It might be work!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.