zoukankan      html  css  js  c++  java
  • tabhost中activity跳转动画不显示的解决办法

    【1】如果是tabhost中的activity跳到其他的activity,用这篇blog的方法即可

    http://blog.sina.com.cn/s/blog_8db8914301010t31.html

    public class AnimCommon {

    public static int in = 0;
    public static int out = 0;
    public static void set(int a, int b){
    in = a ;
    out = b;
    }
    public static void clear(){
    in = 0;
    out = 0;
    }
    }
    下面是tabactivity 类的onPause()
    @Override
    protected void onPause() {
    System.out.println("pause");
    if(AnimCommon.in!=0 && AnimCommon.out!=0){
    super.overridePendingTransitio n(AnimCommon.in, AnimCommon.out);
    AnimCommon.clear();
    }
    super.onPause();
    }

    下面是跳转时的代码:
    Intent intent = new Intent(InformActivity.this, InformItemActivity.class);
    AnimCommon.set(R.anim.zoom_enter,R.anim.zoom_exit); 
    startActivity(intent);

    这样就可以解决这个问题了。

    【2】如果是tabhost里面的两个activity

    那么用以下代码

    getTabHost().setOnTabChangedListener(new OnTabChangeListener() {
        public void onTabChanged(String tabId)
        {
               View currentView = getTabHost().getCurrentView();
               if (getTabHost().getCurrentTab() > currentTab)
               {
                   currentView.setAnimation( inFromRightAnimation() );
               }
               else
               {
                   currentView.setAnimation( outToRightAnimation() );
               }


               currentTab = getTabHost().getCurrentTab();
        }
    });

     
    public Animation inFromRightAnimation()
    {
       Animation inFromRight = new TranslateAnimation(
               Animation.RELATIVE_TO_PARENT, +1.0f,
               Animation.RELATIVE_TO_PARENT, 0.0f,
               Animation.RELATIVE_TO_PARENT, 0.0f,
               Animation.RELATIVE_TO_PARENT, 0.0f);
       inFromRight.setDuration(240);
       inFromRight.setInterpolator(new AccelerateInterpolator());
       return inFromRight;
    }


    public Animation outToRightAnimation()
    {
       Animation outtoLeft = new TranslateAnimation(
               Animation.RELATIVE_TO_PARENT, -1.0f,
               Animation.RELATIVE_TO_PARENT, 0.0f,
               Animation.RELATIVE_TO_PARENT, 0.0f,
               Animation.RELATIVE_TO_PARENT, 0.0f);
       outtoLeft.setDuration(240);
       outtoLeft.setInterpolator(new AccelerateInterpolator());
       return outtoLeft;
    }

  • 相关阅读:
    SourceTree 3.3.6安装跳过注册安装
    Qt Framework 问题之 framework/Versions/A:bundle format unrecognized, invalid, or unsuitable
    数据结构之栈
    数据结构之单链表
    数据结构之数组
    QPixmap 在非QtCreator环境下无法显示jpg图片
    Mac端StartUML的安装和破解
    C++实现根据路径读取文件内容
    迁移至知乎
    XDRender_LightModeFeature_CauseLight 焦散1-DropRain
  • 原文地址:https://www.cnblogs.com/aukle/p/3235241.html
Copyright © 2011-2022 走看看