在毕加索动画加载图像 [英] Animated loading image in picasso

查看:222
本文介绍了在毕加索动画加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code加载在毕加索的图像,利用绘制的占位符时显示的图像被下载。我想虽然是一个动画纺纱进度条样式微调的动画一圈又一圈,而图像加载,就像我在最专业的应用程序看到。毕加索似乎并不支持这一点,只有静态图像可绘制。有没有办法得到它的工作与毕加索或做我必须做不同的东西?

  Picasso.with(上下文).load(URL)
                    .placeholder(R.drawable.loading)
                    .error(R.drawable.image_download_error)
                    。走进(视图);
 

解决方案

如何使用毕加索占位符有一个加载进度动漫形象:

我解决了这个容易使用的动画,旋转XML对象。

步骤:

  

progress_image.png

  

/res/drawable/progress_animation.xml

 < XML版本=1.0编码=UTF-8&GT?;

<动画,旋转的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:可绘制=@可绘制/ progress_image
    机器人:pivotX =50%
    机器人:pivotY =50%/>
 

  

毕加索加载:

  Picasso.with(上下文)
        .load(您的路径)
        .error(R.drawable.ic_error)
        .placeholder(R.drawable.progress_animation)
        。走进(image_view);
 

我希望这有助于!

I have the following code to load an image in Picasso, using a drawable for the placeholder to display while the image is downloading. What I want though is an animated spinning progress bar style spinner that animates around and around while the image is loading, like I see in most professional apps. Picasso doesn't seem to support this, only static image drawables. Is there a way to get it working with Picasso or do I have to do something different?

Picasso.with(context).load(url)             
                    .placeholder(R.drawable.loading)
                    .error(R.drawable.image_download_error)
                    .into(view);

解决方案

How to have a loading progress animation image using Picasso placeholder:

I solved this easily using a animated-rotate xml object.

Steps:

progress_image.png

/res/drawable/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%"/>

Picasso loading:

Picasso.with( context )
        .load( your_path )
        .error( R.drawable.ic_error )
        .placeholder( R.drawable.progress_animation )
        .into( image_view );

I hope this helps!

这篇关于在毕加索动画加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆