【发布时间】:2014-09-30 14:53:44
【问题描述】:
嗨,我想在下载图像时为我的画廊中的 imageViews 设置动画(尽管我知道它已被弃用)。它适用于看起来很糟糕的动画集,但我希望有一个类似 android 的旋转进度指示器。我已经搜索了几个小时,但没有找到可以解决我的问题的方法。
// getView of my ImageAdapter for gallery
public View getView(int position, View convertView, ViewGroup parent)
{
...
if(image != null){
//set the downloaded image and stop animation
imageView.setAnimation(null);
imageView.setImageBitmap(images.get(position));
}
else{
//display loading animation
// this works - but looks crappy
//R.drawable.loading is animation-set with 5 images
//imageView.setBackgroundResource(R.drawable.loading);
//AnimationDrawable anim = (AnimationDrawable) imageView.getBackground();
//anim.start();
//this leads to my problem
//R.drawable.loading_circle is .png which looks like the android one
//R.anim.rotate is infinite 360 degree rotation
imageView.setBackgroundResource(R.drawable.loading_circle); // wont work with .setImageResource() too
imageView.startAnimation(AnimationUtils.loadAnimation(imageView.getContext(), R.anim.rotate));
}
...
}
但这不会按预期工作(我创建了一个显示我的问题的图像 - 但我无法发布它 - 所以这里有一个链接 http://s1.directupload.net/images/140807/kmws7pi2.png)...
- 只有在 Gallery 的 imageView 包含图像时才会启动动画(但无论如何动画都应该停止)
- 只有在 imageView 为空时,动画才会随 imageView 一起移动
提前致谢!
【问题讨论】:
-
您放置图像的列表视图项布局.. 放置进度条并使进度条(圆形)可见并隐藏图像视图。下载图像时隐藏进度条并显示带有下载图像集的图像视图。
-
这并不容易,因为我使用的是画廊而不是水平列表视图或类似的东西......我不能(或不知道是否可能)将画廊内的 imageView 设置为布局
标签: android animation imageview gallery