让动画像换页时,刷卡 [英] make animation like page changing when swiped

查看:254
本文介绍了让动画像换页时,刷卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我用SimpleGestureFilter.java和它呼吁刷卡右边的功能是什么应用程序(左右双击...等),这里是code的一部分

  @覆盖
    公共布尔dispatchTouchEvent(MotionEvent我){
        //调用onTouchEvent SimpleGestureFilter类
         this.detector.onTouchEvent(箱);
       返回super.dispatchTouchEvent(箱);
    }
    公共无效onSwipe(INT方向){
      字符串str =;      开关(方向){      情况下SimpleGestureFilter.SWIPE_RIGHT:minusOne();海峡=刷卡右;
                                               打破;
      案例SimpleGestureFilter.SWIPE_LEFT:Plusone精选();海峡=向左滑动
                                                     打破;      }     }

所以我想这样做的时候Plusone精选()被caled或一些其他的功能它做一些事情,并将其提交同一类MainActivity.java意图,我想,当该事件发生,看起来像一个才达到书页的幻灯片,有somesort屏幕之间的转换altought它只有一个MainActivity屏幕

 意向书I =新意图(这一点,MainActivity.class);
  i.putExtra(DBAdapter.KEY_pk_ymd,的Integer.parseInt(DT));
  startActivityForResult(ⅰ,ACTIVITY_EDIT);


解决方案

使用:push_left_in.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<设置的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:插值=@机器人:动画/ accelerate_interpolator>
 <翻译Android:fromXDelta =100%p的机器人:toXDelta =0机器人:时间=300/>
<阿尔法机器人:fromAlpha =0.0机器人:toAlpha =1.0机器人:时间=300/>

和push_left_out.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<设置的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:插值=@机器人:动画/ accelerate_interpolator><翻译Android:fromXDelta =0安卓toXDelta = - 100%P机器人:时间=300/>
    <阿尔法机器人:fromAlpha =1.0机器人:toAlpha =0.0机器人:时间=300/>
< /集>

所有的XML都位于RES /动画,被称为像这样

 意向书I =新意图(这一点,MainActivity.class);
    startActivityForResult(ⅰ,ACTIVITY_EDIT);
    overridePendingTransition(R.anim.push_left_in,R.anim.push_left_out);

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);

解决方案

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);    

这篇关于让动画像换页时,刷卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆