Placeholder/Error/Fallback in Glide v4 [duplicate]

无人久伴 提交于 2019-12-22 04:39:36

问题


i am using latest version of Glide as of now which is glide:4.0.0-RC1 and not able to find methods like placeholder, error, fallback e.t.c. Probably they have provided alternate for it but i am not getting it. Anybody know about there alternatives in this release?


回答1:


try this

RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(R.mipmap.ic_launcher);
requestOptions.error(R.drawable.error_img);

Glide.with(this)
                .setDefaultRequestOptions(requestOptions)
                .load("")
                .into(imageViewPlaceholder);



回答2:


Checkout migration details from here. Looks like they had lot more improvements.

You have new class RequestOptions:

RequestOptions options = new RequestOptions()
    .centerCrop()
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.error)
    .priority(Priority.HIGH);

Then,

Glide.with(fragment/activity)
    .load(url)
    .apply(options)
    .into(imageView);

To learn more about Migration Details, you can go here.



来源:https://stackoverflow.com/questions/45187661/placeholder-error-fallback-in-glide-v4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!