Painting a lot of diagrams for a board game I'm creating a chess application and I would like to show plenty of big chess diagrams in scrollview. At the moment I just create ImageView for every diagram, create bitmap into it, paint the diagram on a canvas and that's it.

However, it goes crazy with memory necessary to work. On my quadHD display it uses hundreds of MB even on A4R4G4B4. As I need always to show only a chess board, pieces and arrows, it seems pretty unnecessary to store so much bitmap data as I'm only reusing the same images many times plus painting some polygons. Is there a way to make this more efficiently? Is there a way how to use ImageView without bitmap data, just painting to it when it's on the screen?

public void UpdateLecturePreviewPositionsCount(int newCount)
{
    //Function never removes extra views, but adds views if more then previously necessary
    while (lecturePreviewBoards.Count &lt; newCount)
    {
        lecturePreviewBoards.Add(CreateBoard((xScreen - (NUM_DIAGRAMS_PER_PAGE * 2) * DIAGRAM_PADDING) / NUM_DIAGRAMS_PER_PAGE));
        lecturePreviewBoards[lecturePreviewBoards.Count - 1].imgv.SetPadding(DIAGRAM_PADDING, DIAGRAM_PADDING, DIAGRAM_PADDING, DIAGRAM_PADDING);
        layoutLecturePositionsPreview.AddView(lecturePreviewBoards[lecturePreviewBoards.Count - 1].imgv);
    }
    for (int i = 0; i &lt; newCount; i++)
        lecturePreviewBoards[i].imgv.Visibility = ViewStates.Visible;
    for (int i = newCount; i &lt; lecturePreviewBoards.Count; i++)
        lecturePreviewBoards[i].imgv.Visibility = ViewStates.Gone;

}

public c_image_painting CreateBoard(double dblSize = -1)
{
    if (dblSize &lt; 0)
        dblSize = xScreen;
    int size = (int)dblSize;
    c_image_painting cbp = new c_image_painting();
    cbp.bmp = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb4444);
    cbp.cnv = new Canvas();
    cbp.imgv = new ImageView(context);
    cbp.cnv.SetBitmap(cbp.bmp);
    cbp.imgv.SetImageBitmap(cbp.bmp);
    return cbp;
}

public class c_image_painting
{
    public Canvas cnv;
    public Bitmap bmp;
    public ImageView imgv;
    private Bitmap.Config bmpFormat;
    public c_image_painting()
    {
        bmpFormat=Bitmap.Config.Argb4444;
    }
    public c_image_painting(Bitmap.Config bc)
    {
        bmpFormat = bc;
    }
}
Instead of rendering the bitmap in memory, you could define a custom view that takes a Board and renders it.

I did this for an Android app for a variant of the Go board game, and it worked pretty well. The basic idea of this AbstractBoardView is to have the board state somewhere and to connect it to a view so that it can be drawn.

The memory requirements for this class are exceptionally low, compared to a precomputed bitmap. Even more because my implementation doesn't even hold the board state, it just provides access to it via abstract methods.