Android Question Canvas panels yet again

rodmcm

Active Member
Licensed User
I have tried unsuccessfully to draw a background ( changeable within the program) and draw bitmap marbles on this background.
The marbles are drawn on cvs2.
I have tried three ideas for the background as per searching on this site.
a) BackgroundBitmap on a panel,
b) Background bitmap on another canvas cvs1
c) Mutable bitmap into cvs2

I can get the marbles to correctly operate on cvs2 working alone
I can get the background to show on the panel (a) but the marbles are not shown
Whenever I put a background (b or c) with the marbles I get nothing

In B4j I got used the (b) method with the marbles with no problems

Any ideas?

Happy Xmas as well
B4X:
ub SetUpBoard
    DrawBackground3     '1 or 2 or
    ShowMarbles
End Sub


' Draws background on panel
Sub DrawBackground1
    Log("DrawBackground 1")
    Dim bd As BitmapDrawable
    bd.Initialize(LoadBitmap(File.DirAssets, "Board_British.bmp"))
    bd.Gravity = Gravity.FILL
    pnl1.Background = bd
End Sub
   
'Draws background bitmap on CVS1
Sub DrawBackground2
    Log("DrawBackground 2")
    Dim DestRect As Rect
    DestRect.Initialize(0,0,pnl1.Width,pnl1.Height)
    Dim bx As Bitmap
    bx = LoadBitmap(File.DirAssets,"Board_British.bmp")
    cvs1.DrawBitmap(bx, Null, DestRect)
    pnl1.Invalidate
End Sub


'Draws background on CVS2, should be drawable with canvas
Sub DrawBackground3
    Log("DrawBackground 3")
    Dim bx As Bitmap
    bx = LoadBitmap(File.DirAssets,"Board_British.bmp")
    bx.InitializeMutable(700dip,700dip)
    cvs2.Initialize2(bx)
    pnl1.Invalidate
End Sub

'Shows marbles (Marble(x,y)=1) om CVS2
Sub ShowMarbles
    Log("Show Marbles")
    cvs2.DrawColor(Colors.Transparent)
    Dim DestRect As Rect
    For x=0 To 6
        For y= 0 To 6
            If Marbles(x,y) =1 Then
                DestRect.Initialize(50+x*90, 50+y*90, 50+x*90+60, 50+y*90+60)
                cvs2.DrawBitmap(MarbleBitmap, Null, DestRect)
            End If
        Next
    Next
    pnl1.Invalidate
End Sub
 
Top