I'm fairly new to the android platform and I overrode a CustomView's onDraw method with canvas.drawPath(path, paint)
in order to produce drawings on the page.
However, I attempted to save this drawing to be used in another activity (final page) where multiple saved drawings can be displayed side by side, but I ran into frequent issues with no images appearing on my final page.
I was wondering how to handle this scenario. I read posts on SO about storing the drawing as a bitmap and reconstructing this later. So I used Convert view to bitmap on Android
public static Bitmap getBitmapFromView(View view) { ...
to extract a bitmap from my custom view containing the original drawing. Then, I created a canvas with the extracted bit map using
Bitmap map = getBitmapFromView(cView);
Canvas canvas = new Canvas(map);
and appended this canvas to a static list of Canvas objects.
In the activity used to display all drawings side by side, I had
RelativeLayout layout = (RelativeLayout) findViewById(R.id.activity_display);
for (int x=0; x < canvasList.size(); x++) {
Canvas currCanvas = canvasList.get(x)
View view = new View(this);
view.draw(currCanvas);
layout.addView(canvasList.get(x));
}
There is definitely something wrong with my approach, but I have failed to identify it.