我想ListView
用不同的动画为每个项目设置动画,即使列表处于空闲状态,即它不是滚动或翻转状态。我只知道它可以通过连续动画来完成,但它不能正常工作Handler
。Runnable
请为此提出一些建议。
问问题
674 次
1 回答
1
在自定义 adpater 的 getview 方法中添加动画。像这样,
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.simple_row, parent, false);
ImageView image = (ImageView) rowView.findViewById(R.id.image);
if(position==0)
{
mAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 1.0f);
mAnimation.setDuration(10000);
mAnimation.setRepeatCount(-1);//here we set repeat count to unlimited, so that the animation will run continuously
mAnimation.setRepeatMode(Animation.REVERSE);
mAnimation.setInterpolator(new LinearInterpolator());
image.setAnimation(mAnimation);
}
else if(position==1)
{
//your second animation
}
return rowView;
}
于 2013-05-24T06:12:21.473 回答