为listview的item添加动画效果

     //动画集合
        AnimationSet animationSet = new AnimationSet(true);
        //alpha动画
        Animation animation = new AlphaAnimation(0.0f,1.0f);
        animation.setDuration(1300);
        animationSet.addAnimation(animation);
        //位移动画 效果 从Y方向下落到自己的位置 
        //RELATIVE_TO_SELF 相对自身
        //-1.0f 起始Y坐标为自身的高度
        //TranslateAnimation(int fromXType, float fromXValue, 
        //                   int toXType,   float toXValue, 
        //                   int fromYType, float fromYValue, 
        //                   int toYType,   float toYValue)
        animation = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,
                Animation.RELATIVE_TO_SELF,-1.0f,Animation.RELATIVE_TO_SELF,0.0f);
        animation.setDuration(1300);
        animationSet.addAnimation(animation);
        //设置子视图动画及持续时间
        LayoutAnimationController controller = new LayoutAnimationController(animationSet,0.5f);
        //绑定到listview
        mListView.setLayoutAnimation(controller);

 

posted @ 2016-03-21 17:50  随易来了  阅读(1082)  评论(0编辑  收藏  举报