Yes, I tried to initialize it with a label generated from codes. But it does not work.
Dim Canvas1 as Canvas
Dim lbl as Label
Dim width as Float
Label.Initialize("Label")
Canvas1.Initialize(lbl)
width = Canvas1.MeasureStringWidth(t, Typeface.DEFAULT, 14)
I can initialize Canvas by a Label from Designer but not from codes.
Yes, I tried to initialize it with a label generated from codes. But it does not work.
Dim Canvas1 as Canvas
Dim lbl as Label
Dim width as Float
Label.Initialize("Label")
Canvas1.Initialize(lbl)
width = Canvas1.MeasureStringWidth(t, Typeface.DEFAULT, 14)
I can initialize Canvas by a Label from Designer but not from codes.
Don is Correct. Your local label is not owned by anything (it is not added to Activity).
The Label (or panel) has to be added to Activity before you can use the Label's canvas.
You may find it easier to use a bitmap if your view has not already been added to the activity.