【发布时间】:2015-10-06 23:13:28
【问题描述】:
我这样使用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%"/>
并将这个动画放在我的Picassocall 中:
Picasso.with( context )
.load( your_path )
.error( R.drawable.ic_error )
.placeholder( R.drawable.progress_animation )
.into( image_view );
我的问题是动画没有运行。此外,它不是图像中间的微小加载指示器,而是加载图像被拉伸到图像的尺寸。
如何向 Android Picasso 添加加载指示器?
【问题讨论】:
-
使用不同形式的动画drawable,例如an
AnimationDrawable。 “而且它不是图像中间的微小加载指示器,而是加载图像被拉伸到图像的尺寸” - 您需要设置您的可绘制对象以根据需要设置填充。animated-rotate可能有它的属性(我没有看到或使用过);对于AnimationDrawable,您提供框架,因此会将填充放在框架图像本身中。 -
能否请您在答案中发布一个示例?
标签: java android android-studio