Reputation: 1472
I created ScrollView
and TableLayout
dynamically.
How can I add my graphics (Canvas
) in ImageView
?
Canvas canvas = new Canvas();
...
canvas.DrawPath(path, paint);
ImageView imageView = new ImageView(this);
Bitmap bitmap = Bitmap.CreateBitmap(2000, 2000, Bitmap.Config.Argb8888);
canvas.DrawBitmap(bitmap, 200, 200, paint);
button.Text = bitmap.Width + ";" + bitmap.Height;
imageView.SetImageBitmap(bitmap);
tableLayout.AddView(imageView);
Upvotes: 0
Views: 1738
Reputation: 16771
If you want whatever a canvas draws to appear in an ImageView, you need to create the canvas with a bitmap, then perform your drawing logic.
Here's an example based on your code:
// 2000x2000 is VERY large for an Android bitmap - consider using a smaller size?
// You may see out of memory errors with this size.
Bitmap bitmap = Bitmap.CreateBitmap(2000, 2000, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawPath(path, paint);
imageView.setImageBitmap(bitmap);
Upvotes: 1