3

i have an application for which i use SimpleGestureFilter.java and what it does is calling the right function on swipe (left right double tap...etc) here is part of the code

     @Override
    public boolean dispatchTouchEvent(MotionEvent me){
        // Call onTouchEvent of SimpleGestureFilter class
         this.detector.onTouchEvent(me);
       return super.dispatchTouchEvent(me);
    }
    public void onSwipe(int direction) {
      String str = "";

      switch (direction) {

      case SimpleGestureFilter.SWIPE_RIGHT : minusOne(); str = "Swipe Right";
                                               break;
      case SimpleGestureFilter.SWIPE_LEFT : plusOne(); str = "Swipe Left";
                                                     break;

      }

     }

So what i want to do it when plusOne() is caled or some of the other functions it does something and it submits intent on the same MainActivity.java class , I am trying to achive when that event happens to look like a book page slide , to have somesort of transitions between screens altought it is only one MainActivity screen

      Intent i = new Intent(this,MainActivity.class);
  i.putExtra(DBAdapter.KEY_pk_ymd, Integer.parseInt(dt));
  startActivityForResult(i,ACTIVITY_EDIT);
Deron
  • 352
  • 1
  • 3
  • 15

2 Answers2

4

use : push_left_in.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">    
 <translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>  
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />  

and push_left_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">

<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="300"/>
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

all xml are located in res/anim and are called like this

    Intent i = new Intent(this,MainActivity.class);         
    startActivityForResult(i,ACTIVITY_EDIT);
    overridePendingTransition(R.anim.push_left_in,R.anim.push_left_out);    
denza
  • 1,298
  • 4
  • 24
  • 49
1

You could use this google code here:

https://code.google.com/p/android-3d-flip-view-transition

Once it is imported then you simply use:

AnimationFactory.flipTransition(viewFlipper, FlipDirection.LEFT_RIGHT);

And your good to go, simple effective lib.

EDIT:

Your other option is to include an animation call within your intent, but a page turn would be tricky to do this way. A simple swipe in or swipe out style animation could be implemented:

overridePendingTransition(int enterAnim, int exitAnim)

push_right_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="@android:integer/config_shortAnimTime"/>
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_shortAnimTime" />
</set>


   push_right_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="@android:integer/config_shortAnimTime"/>
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="@android:integer/config_shortAnimTime" />
</set>

Is this closer to what you are after? The lib I posted in the first answer is really easy to use and does give a good effect.

andy
  • 391
  • 13
  • 33
  • 1
    no no i need more simple just to look like something happend in the screen not only to load the data – Deron Dec 20 '13 at 07:26