Android Question Canvas Draw does not display

Discussion in 'Android Questions' started by Alberto Michelis, Aug 12, 2015.

  1. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    Hi,
    Im doing a loop with which I draw boxes and texts using this code:

    Code:
    r.Initialize( Xpos, Ypos, BoxWidth+Xpos, BoxHeight+Ypos)
              c.DrawRect(r, BGcolor, 
    True2)   
           r.Initialize( Xpos, Ypos, BoxWidth+Xpos, BoxHeight+Ypos)
              c.DrawRect(r, 
    Colors.DarkGray, False2)   
            
    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
     
  2. klaus

    klaus Expert Licensed 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.
     
    RandomCoder likes this.
  3. Alberto Michelis

    Alberto Michelis Active Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice