我像这样使用Square Picasso:
Picasso.with(context)
.load(url)
.centerCrop()
.fit()
.into(imageView);
我希望在Picasso加载图像时有一个旋转加载指示器。我试过这里发布的解决方案:
Animated loading image in picasso
Show an "Loading..." image while background loading of image with Picasso
我创建了一个动画:
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress_image"
android:pivotX="50%"
android:pivotY="50%"/>
并把这个动画放在我的Picasso
call中:
Picasso.with( context )
.load( your_path )
.error( R.drawable.ic_error )
.placeholder( R.drawable.progress_animation )
.into( image_view );
我的问题是动画没有运行。此外,它不是图像中间的微小加载指示器,而是加载图像被拉伸到图像的尺寸。
如何在Android Picasso中添加加载指示器?
progress_animation.xml -
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress_image"
android:pivotX="50%"
android:pivotY="50%"/>
and use picasso like this -
Picasso.with(this).load(imageString).placeholder( R.drawable.progress_animation ).into(imageView);