'How to get bitmap in imageView OR picasso
Why does null return?
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
In addition, when I use picasso, it does not goto the onBitmapLoaded method
Picasso.get().load("url").into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
//Does not go to this method
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
//Coming this method
}
});
what's the problem ? Why can't I get a bitmap from imageView? Do you have a solution?
Solution 1:[1]
I used background for imageView must be used src
<ImageView
android:id="@+id/img"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/img"/>
ImageVew imageView = findViewById(R.id.activityGetMainColor_img);
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
Bitmap bitmap = drawable.getBitmap();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
