我可以使用旋转动画在占位符中加载微调器,直到使用 Glide 加载图像?
我正在尝试使用 .placeholder(R.Drawable.spinner) 来做到这一点,没有动画出现?
如果有人可以帮助我,那就太好了?
谢谢!
原文由 Sanjana Nair 发布,翻译遵循 CC BY-SA 4.0 许可协议
我可以使用旋转动画在占位符中加载微调器,直到使用 Glide 加载图像?
我正在尝试使用 .placeholder(R.Drawable.spinner) 来做到这一点,没有动画出现?
如果有人可以帮助我,那就太好了?
谢谢!
原文由 Sanjana Nair 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是我的完整解决方案,带有圆形加载进度。我认为最好使用 requestOptions
属性来实现这一点。
CircularProgressDrawable circularProgressDrawable = new CircularProgressDrawable(context);
circularProgressDrawable.setStrokeWidth(5f);
circularProgressDrawable.setCenterRadius(30f);
circularProgressDrawable.start();
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(circularProgressDrawable);
requestOptions.error(R.drawable.ic_image_not_found);
requestOptions.skipMemoryCache(true);
requestOptions.fitCenter();
glide.load(imagePath) //passing your url to load image.
.load(imagePath)
.apply(requestOptions) // here you have all options you need
.transition(DrawableTransitionOptions.withCrossFade()) // when image (url) will be loaded by glide then this face in animation help to replace url image in the place of placeHolder (default) image.
.listener(requestListener)
.into(view); //pass imageView reference to appear the image.
你明白了。
原文由 Zhar 发布,翻译遵循 CC BY-SA 4.0 许可协议
2 回答1.3k 阅读✓ 已解决
2 回答2.6k 阅读
2 回答1.7k 阅读
1 回答2.1k 阅读
1 回答1.1k 阅读
1 回答1.3k 阅读
1.3k 阅读
编辑: 现在使用 CircularProgressDrawable 超级简单
构建.gradle
MyGlideModule.kt
MainActivity.kt
这些是其他一些 Glide 片段
旧答案: 您也可以创建一个普通的 ProgressBar,然后将其隐藏在 Glide 的
onResourceReady()
上。_示例_:
MainActivity.java
activity_main.xml (布局):
结果: