设为首页 加入收藏

TOP

android TranslateAnimation 顶部segment分段移动动画(四)
2017-10-13 10:36:51 】 浏览:5020
Tags:android TranslateAnimation 顶部 segment 分段 移动 动画
ue为负数时,moveStepValue*0.5f segment是往左移动,正数往右移动,这样动画效果才不会有bug,
moveAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, moveStepValue * 0.5f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); //下面的代码是计算动画的执行时间,如果不计算就会出现切换分段数量不一致,指示器的动画执行速度太快或太慢。 if (moveStepValue < 1) { moveStepValue = moveStepValue * -1; } moveAnimation.setDuration(moveStepValue * 70); moveAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { zhishiqi.clearAnimation(); //移动效果实现之后,还需要将移动segment分段的margin设置一次,如果不设置动画又会反回去,为什么这样我觉得应该是和android是使用xhtml布局的原因。 zhishiqilinearParams.setMargins((currentTopItemIndex - 1) * zhishiqiWidth, margin.topMargin, zhishiqiWidth, zhishiqilinearParams.height); zhishiqi.setLayoutParams(zhishiqilinearParams); } }); zhishiqi.startAnimation(moveAnimation); zhishiqi.setVisibility(View.VISIBLE); } }

 

首页 上一页 1 2 3 4 下一页 尾页 4/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇广播接收者实现IP拨号 下一篇android 在非UI线程更新UI仍然成..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目