I have some XML-Layout generated ImageView and i want to copy the image i click in a LinearLayout below.
I had assign the follow event to all the ImageView's onClick events:
public void onClick(View v) {
    // Take layout where i want to put my copy-image
    LinearLayout savingLayout = (LinearLayout)findViewById(R.id.linearSaved);
    //Create a new image
    ImageView savedImage = new ImageView(savingLayout.getContext());
    //Take the bitmap from the object i clicked
    Bitmap b = ((BitmapDrawable)((ImageView)v).getDrawable()).getBitmap();
    //Take the config of the bitmap. IT RETURNS NULL
    Bitmap.Config cfg= b.getConfig();
    //Copy the Bitmap and assign it to the new ImageView... IT CRASH (cfg == null)
    Bitmap b2 = b.copy(cfg, true);
    savedImage.setImageBitmap(b2);
    savingLayout.addView(savedImage);
}
So why b.getConfig() returns null? There is a workaround?
Thanks
Use Bitmap.Config.ARGB_8888 instead of b.getConfig() as a workaround.  
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With