目前我使用的代码是:
set = new AnimationSet(true); animation = new AlphaAnimation(0.0f,1.0f); animation.setDuration(50); set.addAnimation(animation); animation = new TranslateAnimation( Animation.relative_TO_SELF,0.0f,Animation.relative_TO_SELF,-1.0f,0.0f ); animation.setDuration(150); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set,1.0f); l.setLayoutAnimation(controller); l.setAdapter(ListAdaptor);
然后通过按钮onClick添加项目
l.startLayoutAnimation();
任何其他建议来实现这样的动画.
解决方法 我得到了解决方案.我在自定义适配器的getVIEw方法中为每个添加的元素设置动画.public VIEw getVIEw(int position,VIEw convertVIEw,VIEwGroup parent) { VIEw v = convertVIEw; if (v == null) { LayoutInflater vi = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.simple_List_item_1,null); } ListData o = List.get(position); TextVIEw tt = (TextVIEw) v.findVIEwByID(R.ID.toptext); tt.setText(o.content); Log.d("ListTest","position : "+position); if(flag == false) { Animation animation = AnimationUtils.loadAnimation(getActivity(),R.anim.slIDe_top_to_bottom); v.startAnimation(animation);} return v; }
从而实现了我所说的动画.
总结以上是内存溢出为你收集整理的将动画添加到Android中的列表视图全部内容,希望文章能够帮你解决将动画添加到Android中的列表视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)