`
liuqun_567
  • 浏览: 36006 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

android path 动画效果 (很酷)

阅读更多
玩过 Path 的朋友一定会被其主页的功能按钮动画所吸引,觉得很神奇。
废话不多说,直接贴代码, 完整代码请下载。
附源码

private static void startAnimationsIn(ViewGroup viewgroup)
    {
        int count = viewgroup.getChildCount();
        for(int i=0; i<count; i++){
        if(viewgroup.getChildAt(i) instanceof InOutImageButton)
            {
                InOutImageButton imgView = (InOutImageButton)viewgroup.getChildAt(i);
                ComposerButtonAnimation animation = new ComposerButtonAnimation(InOutAnimation.Direction.IN, 200, imgView);
                long startOffset = i * 100 / (count -1);
                animation.setStartOffset(startOffset);
                animation.setInterpolator(new OvershootInterpolator(2F));
                imgView.startAnimation(animation);
            }
        }
    }

    private static void startAnimationsOut(ViewGroup viewgroup)
    {
   
        int count = viewgroup.getChildCount();
        for(int i=0; i<count; i++){
        if(viewgroup.getChildAt(i) instanceof InOutImageButton)
            {
                InOutImageButton inoutimagebutton = (InOutImageButton)viewgroup.getChildAt(i);
                int direction = InOutAnimation.Direction.OUT;
                ComposerButtonAnimation anim = new ComposerButtonAnimation(direction, 200, inoutimagebutton);
                long startOffset = (count -1 - i) * 100 / (count -1);
                anim.setStartOffset(startOffset);
                anim.setInterpolator(new AnticipateInterpolator(2F));
                inoutimagebutton.startAnimation(anim);
            }
        }
   
    }

    protected void addInAnimation(View aview[])
    {
        ViewGroup.MarginLayoutParams marginlayoutparams = (ViewGroup.MarginLayoutParams)aview[0].getLayoutParams();
        float fromX = -marginlayoutparams.leftMargin + xOffset;
        float fromY = marginlayoutparams.bottomMargin - 13;
        TranslateAnimation anim = new TranslateAnimation(fromX, 0F, fromY, 0F);
        addAnimation(anim);
    }

    protected void addOutAnimation(View aview[])
    {
        android.view.ViewGroup.MarginLayoutParams marginlayoutparams = (android.view.ViewGroup.MarginLayoutParams)aview[0].getLayoutParams();
        float toX = -marginlayoutparams.leftMargin + xOffset;
        float toY = marginlayoutparams.bottomMargin - 13;
        TranslateAnimation anim = new TranslateAnimation(0F, toX, 0F, toY);
        addAnimation(anim);
    }
  • 大小: 18.5 KB
分享到:
评论
6 楼 qiliannujian 2013-09-26  
相当不错但是我需要把他放到中间  扇形开花怎么办呢
5 楼 vary25 2013-01-21  
效果非常棒 ,感谢分享
4 楼 zy88882008 2012-08-11  
特别好。。。。 
3 楼 xiaojuanmu 2012-07-18  
不错
2 楼 yfsp 2012-07-11  
不能编译啊
1 楼 zcmtmxk 2012-06-13  
很酷的效果,研究一下。感谢分享

相关推荐

Global site tag (gtag.js) - Google Analytics