Android Question Canvas Draw does not display

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi,
Im doing a loop with which I draw boxes and texts using this code:

B4X:
       r.Initialize( Xpos, Ypos, BoxWidth+Xpos, BoxHeight+Ypos)
          c.DrawRect(r, BGcolor, True, 2)   
       r.Initialize( Xpos, Ypos, BoxWidth+Xpos, BoxHeight+Ypos)
          c.DrawRect(r, Colors.DarkGray, False, 2)   
        If BoxWidth<80 Then
            c.DrawTextRotated(HeatEspecie&" "&HeatDia&"%",Xpos+10,Ypos+30,Typeface.DEFAULT,10,FGcolor,"LEFT",90)
            'c.DrawTextRotated(HeatDia&"%",Xpos+10,Ypos+60,Typeface.DEFAULT,10,Colors.DarkGray,"LEFT",90)
        Else   
            c.DrawText(HeatEspecie,Xpos+10,Ypos+30,Typeface.DEFAULT,10,FGcolor,"LEFT")
            c.DrawText(HeatDia&"%",Xpos+10,Ypos+60,Typeface.DEFAULT,10,FGcolor,"LEFT")
        End If

Problem is the boxes and texts does no appears in the screen till I touch it.
What am I doing wrong?
Thanks
 

klaus

Expert
Licensed User
Longtime User
You must Invalidate the view of the Canvas after the drawing.
Example: Activity.Invalidate
You can either Invalidate the whole view or only a rectangular part with
Activity.Invalidate2(Rect) or
Activity.Invalidate3(Left, Top, Right, Bottom)

This forces a view update.
 
Upvote 0
Top