Android Question [Solved] canvas.drawtext with csbuilder: colors

Pflichtfeld

Active Member
Licensed User
It is possible, to pass a csbuilder-object to the text-parameter of a canvas.drawtext. But its colors are overwritten by the color-parameter of the drawtext-method. It is not accepted, to pass anything else then an int for the color-parameter.
Is there a way, to get the colors of the csbuilder-object in drawtext of canvas?
 

Pflichtfeld

Active Member
Licensed User
I don't know what you are trying to do but you should check BBCodeView.
Thank you Erel,
I wanted to display severel numbers in one line in different colors in a drawing. Did it now with canvas.measuretext.
 

Pflichtfeld

Active Member
Licensed User
Perfect! Thank you!
May I ask you a question about the given example?
B4X:
Sub TextToBitmap (Width As Int, Fnt As B4XFont, Clr As Int, Text As Object) As B4XBitmap
   Dim lbl As Label
   lbl.Initialize("")
   Dim x As B4XView = lbl
1. are the lines:
B4X:
   Dim lbl As Label
   lbl.Initialize("")
cross-platform?

2. Would this also do? (but there is no initialize-Method for a b4xview)
B4X:
Sub TextToBitmap (Width As Int, Fnt As B4XFont, Clr As Int, Text As Object) As B4XBitmap
   Dim x As B4XView
 

Pflichtfeld

Active Member
Licensed User
It seems that I have not understood this crossplattform topic:
I thought that all the b4xviews are crossplatform and the 'normal' b4a-views are not.
So I assumed, that
B4X:
Dim lbl As Label
lbl.Initialize("")
would not be crossplatform. Isn't that right?
 
Top