Drawing on canvas leaves behind old text

joolzg

Member
Licensed User
Longtime User
Ok making progress.

Sub ShowChannelInfo
Dim rect1 As Rect

rect1.Initialize(5%x, 2%y, 5%x+64, 2%y+64)
canvas1.DrawBitmap( cCurrent.pIcon, Null, rect1)
'canvas1.DrawLine( 10,10,500,50,Colors.Blue,5dip)
canvas1.DrawText( cCurrent.cNumber, 5%x, 18%y, Typeface.DEFAULT_BOLD, 24, Colors.White, "LEFT")
canvas1.DrawText( cCurrent.cName, 5%x, 22%y, Typeface.DEFAULT_BOLD, 24, Colors.White, "LEFT")
canvas1.DrawText( DateTime.Time(DateTime.Now).SubString2(0,5), 97%x, 5%y, Typeface.DEFAULT_BOLD, 30, Colors.White, "RIGHT")
rect1.Initialize(30%x, 2%y, 90%x, 20%y)
canvas1.DrawRect( rect1, Colors.LightGray, True, 1dip)
channelInfo.Invalidate
End Sub

But the problem is that when i change channel the old information is still there and the new stuff adds on top of it.

Whats the correct wat of clearing the old text and bitmaps?

I tried this but i lose my transparency

canvas1.DrawColor( Colors.ARGB( 255, 128, 128, 128))

I tired this but no difference

canvas1.DrawColor( Colors.ARGB( 255, 128, 128, 128))
canvas1.DrawColor( Colors.ARGB( 127, 128, 128, 128))

Also a 2nd question, how do i make this code work on different sized displays, just tried on my Galaxy 3 and everything is too big, mostly in the right place, just too large

joolz
 

COBRASoft

Active Member
Licensed User
Longtime User
You have to 'erase' the canvas by drawing a filled rectangle with Colors.Transparent. This will actually clear all the previous stuff you placed on it
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
Thanks help out, working now.

So can you give me a pointer to how i get my drawing code to work on a phone and a tablet and chinese box, with everything scaled correctly?

joolz
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
Sure, use % in your widths and heights for relative positioning. Use dip or diptocurrent to 'scale' an absolute value. Erel can explain this deeper :).
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
Thanks for the reply, ive used % on my x,y coords but how do i scale the bitmap and the fonts correctly

joolz
 
Upvote 0
Top