Reputation: 211
How do I set background image for text with glide?
file[0] = "mnt/sdcard/sort_icon.png"
SimpleTarget target = new SimpleTarget<Drawable>(){
@Override
public void onResourceReady(Drawable resource, GlideAnimation<? super Drawable> glideAnimation) {
txtView.setBackground(resource);
}
};
Glide.with(getBaseContext())
.load(file[i-4])
.into(target);
Upvotes: 2
Views: 4020
Reputation: 10125
Solution:
Try this:
Add the implementation in your gradle
(app):
dependencies {
.....
.....
def glide = "4.8.0"
// Glide
implementation "com.github.bumptech.glide:glide:$glide"
annotationProcessor "com.github.bumptech.glide:compiler:$glide"
.....
}
Then, in your Activity/Fragment
:
File file = new File(file[i-4]);
Uri imageURI = Uri.fromFile(file);
Glide.with(MainActivity.this)
.load(imageURI)
.apply(RequestOptions.placeholderOf(R.drawable.ic_launcher))
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource,
@Nullable Transition<? super Drawable> transition) {
txtView.setCompoundDrawablesWithIntrinsicBounds(resource, null, null, null);
}
});
See if it works.
Upvotes: 2