您的位置:首页 > 移动开发 > Android开发

Android Animation与ListView结合的滑动效果

2014-05-11 22:23 190 查看
目标效果图:


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

代码片段:

@Override
public 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效果
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android listview animation
相关文章推荐