gpt4 book ai didi

android - picasso 中的动画加载图像

转载 作者:IT老高 更新时间:2023-10-28 13:03:53 25 4
gpt4 key购买 nike

我有以下代码在 Picasso 中加载图像,使用可绘制的占位符在图像下载时显示。不过,我想要的是一个动画旋转进度条样式的微调器,它在图像加载时左右移动,就像我在大多数专业应用程序中看到的那样。 picasso 似乎不支持这一点,只有静态图像可绘制。有没有办法让它与 picasso 一起工作,还是我必须做一些不同的事情?

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

最佳答案

如何使用 picasso 占位符获得加载进度动画图像:

我使用动画旋转 xml 对象轻松解决了这个问题。

步骤:

progress_image.png

progress_image.png

/res/drawable/progress_animation.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:gravity="center">
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress_image"
android:pivotX="50%"
android:pivotY="50%" />
</item>
</layer-list>

picasso 加载:

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

关于android - picasso 中的动画加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24826459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com