I have an XML Layout created by ImageView and I want to copy the image that I click below LinearLayout.
I assigned a follow event to all events ImageView onClick:
public void onClick(View v) {
LinearLayout savingLayout = (LinearLayout)findViewById(R.id.linearSaved);
ImageView savedImage = new ImageView(savingLayout.getContext());
Bitmap b = ((BitmapDrawable)((ImageView)v).getDrawable()).getBitmap();
Bitmap.Config cfg= b.getConfig();
Bitmap b2 = b.copy(cfg, true);
savedImage.setImageBitmap(b2);
savingLayout.addView(savedImage);
}
So why does it b.getConfig()return null? Is there a workaround?
thank
source
share