DrawText not appearing?

PenguinHero

Member
Licensed User
Longtime User
Hi All,

I wanted to create a Gradient on a panel, and then write text to it.
I found a couple of different bits of code here on the forums and from the beginners guide. But when I combine them it doesn't work.

This is the code I'm using, and I tried it on both my device (a Kindle Fire) and on the virtual device. In both tests I get the gradient but no text.

I don't get any errors, but I'm guessing I've broken some coding rule?
Or is the text appearing somewhere I can't see? Like under the panel?

What am I doing wrong?

B4X:
Sub Globals
  Dim pnlTest As Panel
  Dim csvTest As Canvas
  Dim gdwGradient As GradientDrawable
  Dim Cols(2) As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)

  pnlTest.Initialize("pnlTest")
  Activity.AddView(pnlTest, 0, 0, 100%x, 100%y)
  csvTest.Initialize(pnlTest)
  
  Cols(0) = Colors.RGB(112,255,148)
  Cols(1) = Colors.White
  gdwGradient.Initialize("TOP_BOTTOM", Cols)
  gdwGradient.CornerRadius = 10dip
  pnlTest.Background = gdwGradient
  
  csvTest.DrawText( "Test", 25dip, 25dip, Typeface.DEFAULT, 30, Colors.Blue, "LEFT")

End Sub

Thanks.
 

PenguinHero

Member
Licensed User
Longtime User
Add pnlTest.Invalidate after drawing on it.

I tried that and it made no difference.

And the example that I got the DrawText from (that works fine for me) in the guide/tutorial (SimpleDrawFunctions) doesn't seem to call it either, except when it calls DrawCircle.

Is it something else?
 
Upvote 0
Top