I am trying to write my first B4X cross-platform (B4J/B4A) application. I am using a class based around a B4XCanvas to draw on a scrollpane/scrollview inner pane/panel passed by the B4J/B4A main form/activity. This all works well until I need to clear the drawing area. In the B4J application the canvas clears and the drawing area is again white and empty as I would expect, but in the B4A activity the drawing area clears to black. Here is a simple project (not the real project) that demonstrates the same behaviour ...
This is the main activity ...
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Here is the class module ...
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Thanks for any pointers. The project is attached.
			
			This is the main activity ...
			
				B4X:
			
		
		
		Sub Process_Globals
    Private s As sketch
End Sub
Sub Globals
    Private scrMain As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("scroller")
    scrMain.Panel.Width = 100%x
    scrMain.Panel.Height = scrMain.Panel.Width
    If FirstTime Then s.Initialize(scrMain.Panel)
End Sub
Sub Activity_Resume
    s.draw
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
	Here is the class module ...
			
				B4X:
			
		
		
		Sub Class_Globals                        ' "sketch" class object
    Dim xui As XUI
    Dim cvs As B4XCanvas
    Dim tmr As Timer
    Dim switch As Boolean = True
End Sub
Public Sub Initialize(v As B4XView)
    cvs.Initialize(v)
    tmr.Initialize("timer", 2000)
End Sub
Sub draw
    Dim r As B4XRect
    r.Initialize(40dip, 40dip, 300dip, 100dip)
    cvs.DrawRect(r, xui.Color_Red, True, 0)           ' The rectangle is drawn even without "cvs.Invalidate" - Why?
    tmr.Enabled = True
End Sub
Sub timer_Tick
    If switch Then draw
    If Not(switch) Then cvs.ClearRect(cvs.TargetRect)
    ' The canvas is cleared to black - Why?    How can I clear it to some other colour?
    cvs.Invalidate                ' This is necessary this time
    switch = Not(switch)
End Sub
	Thanks for any pointers. The project is attached.