I am a little surprised at the strange behavior of canvas and panel. When I create a panel, give it a color and create a canvas (no color, just the canvas) the color of the panel disappears. Does a canvas have a basic color, white? If I assign a color to the panel after creating the canvas, it will appear. I don't understand the behavior. If I only create the canvas, why does this override the panel color?
example:
example:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim tpanel As Panel
Dim tcanvas As Canvas
Dim trect As Rect
tpanel.Initialize("tpanel")
tpanel.Color=Colors.Blue
Activity.AddView(tpanel,0,0,Activity.Width,Activity.Height)
tpanel.Color=Colors.Blue
tcanvas.Initialize(tpanel)
tpanel.Color=Colors.Blue ' without this line, the panel+canvas remains colorless, why?
' trect.Initialize(0,0,Activity.Width,Activity.Height)
' tcanvas.DrawRect(trect,Colors.Transparent,True,0)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
End Sub