Android Question Cannot can text on Canvas

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I try to generate a bitmap with a background color and text on it. I only get the background color.

This is my code:
B4X:
Dim Foto as Bitmap
Dim cnvPnl As Canvas
Dim imv As ImageView
If  imv.IsInitialized = False Then
    imv.initialize("")
    Activity.AddView(imv,10dip,10dip,200dip,200dip)
    imv.Gravity=Gravity.FILL
End If
imv.Visible=False
imv.Color=Colors.blue
cnvPnl.Initialize(imv)
cnvPnl.DrawText("AH",0,0,Typeface.DEFAULT,30,Colors.Yellow,"CENTER")
Foto=cnvPnl.Bitmap

What is wrong?
Is there an easier way to generate this bitmap?

BR, André
 

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I just find what was wrong:
B4X:
cnvPnl.DrawText("AH",0,0,Typeface.DEFAULT,30,Colors.Yellow,"CENTER")

change to:
B4X:
cnvPnl.DrawText("AH",100,100,Typeface.DEFAULT,30,Colors.Yellow,"CENTER")

BR, ANdré
 
Upvote 0
Top