Android Animation与ListView结合的滑动效果

来源:互联网 发布:尼康官方调焦软件 编辑:程序博客网 时间:2024/05/23 11:53

目标效果图:





主要是重写BaseAdapter的getView()方法时,给布局的item添加Animation动画效果。

代码片段:

@Overridepublic View getView(int position, View convertView, ViewGroup parent) {ViewHolder holder;if(convertView==null){holder = new ViewHolder();convertView = inflater.inflate(R.layout.list_item, null);holder.tv = (TextView)convertView.findViewById(R.id.tv);holder.ll = (LinearLayout)convertView.findViewById(R.id.ll);convertView.setTag(holder);}else{holder = (ViewHolder)convertView.getTag();}holder.tv.setText(list.get(position));ScaleAnimation sa = new ScaleAnimation(0.5f, 1, 0.5f, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);sa.setDuration(500);holder.ll.setAnimation(sa);return convertView;}



项目代码:https://github.com/DevinShine/AnimationDemo

以后会继续增加其它的Animation效果

1 0
原创粉丝点击