通过滑行(URL)成功加载GIF,现在我想让它成为动态壁纸。
(我不想从原始文件夹中加载gif ...)
img = findViewById(R.id.imageView);
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
Glide
.with(this)
.load(gifUrl)
.placeholder(R.drawable.loading)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
})
//.asGif()
.error(R.drawable.loading) // show error drawable if the image is not a gif
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(img);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Hello", Toast.LENGTH_SHORT).show();
......................
}
});
}
每当点击gif时,设置为壁纸应该继续......