我正在尝试将动画添加到我的应用程序中,该动画将隐藏或在单击时显示菜单.基本上类似于pulse新闻阅读器的文章观点.我能够为菜单容器设置动画.但是,菜单不会在主容器为菜单持有者创建空间的同时向下滑动.我想知道如何解决这个问题.
这是我的动画代码:
if(hoMetabbar.getVisibility() == VIEw.GONE){ hoMetabbar.setVisibility(VIEw.VISIBLE); final Animation tabBlockHolderAnimation = AnimationUtils.loadAnimation(ArticleActivity.this, R.anim.tab_down); tabBlockHolderAnimation.setFillAfter(true); hoMetabbar.startAnimation(tabBlockHolderAnimation);}else{ final Animation tabBlockHolderAnimation = AnimationUtils.loadAnimation(ArticleActivity.this, R.anim.tab_up); tabBlockHolderAnimation.setAnimationListener(new AnimationListener(){ @OverrIDe public voID onAnimationEnd(Animation animation) { // Todo auto-generated method stub hoMetabbar.setVisibility(VIEw.GONE); }});tabBlockHolderAnimation.setFillAfter(true);hoMetabbar.startAnimation(tabBlockHolderAnimation);
解决方法:
public voID toggle() { TranslateAnimation anim = null; isOpen = !isOpen; if (isOpen) { layoutRoot.setVisibility(VIEw.VISIBLE); anim = new TranslateAnimation(0.0f, 0.0f, layoutRoot.getHeight(), 0.0f); } else { anim = new TranslateAnimation(0.0f, 0.0f, 0.0f, layoutRoot.getHeight()); anim.setAnimationListener(collapseListener); } anim.setDuration(300); anim.setInterpolator(new AccelerateInterpolator(1.0f)); layoutRoot.startAnimation(anim);}Animation.AnimationListener collapseListener = new Animation.AnimationListener() { public voID onAnimationEnd(Animation animation) { layoutRoot.setVisibility(VIEw.GONE); } @OverrIDe public voID onAnimationRepeat(Animation animation) { } @OverrIDe public voID onAnimationStart(Animation animation) { }};
总结 以上是内存溢出为你收集整理的Android动画:隐藏/显示菜单全部内容,希望文章能够帮你解决Android动画:隐藏/显示菜单所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)