Reputation: 981
I've extended an ImageView and i've added a line to the canvas in the onDraw method.
@Override
public void onDraw(Canvas canvas) {
if(mBitmap!=null) {
paint.reset();
paint.setXfermode(DUFF_LIGHTEN);
paint.setColor(Color.rgb(0, 0, 0));
paint.setStrokeWidth(30);
canvas.drawLine(0, 100, canvas.getWidth(), 100, paint);
}
}
I can see the line on the screen but when i call the GetDrawable Method i get the original image. UI Canvas (the onDraw one) can't be assigned to another bitmap. This throws an unsupportedoperationexception.
How should i override the getDrawable method to get the image drawed in the screen canvas?
@Override
public Drawable getDrawable() {
return super.getDrawable();
}
I can't use getDrawingCache becouse my image is bigger then screen.
Thank you so much
Upvotes: 0
Views: 591
Reputation: 671
To get Drawable with line you shoud draw on Drawable canvas (convert to bitmap and draw) not on ImageView canvas. Drawing on ImageView canvas not draw on Drawable stored in variable.
Upvotes: 0