Android Question How to get the width of the string in lable

:confused:
determine the width of the label.text and use it as the width of label, no need to use tags
Dim canvas1 As Canvas
Dim bmp As Bitmap
bmp.InitializeMutable(1dip,1dip)
'Dim cvs As Canvas
canvas1.Initialize2(bmp)
Dim ws As Float=canvas1.MeasureStringWidth(nr,Typeface.DEFAULT,14)

This method is feasible
 
Upvote 0
You should not use:
bmp.InitializeMutable(1dip, 1dip)
because on 'old' small devices with a scale of 0.75 you will get an error because 1dip = 0.75 therfore 0.
You should use
bmp.InitializeMutable(2dip, 2dip)
or
bmp.InitializeMutable(1, 1) , but here you get a warning because no dip values.
or
bmp.InitializeMutable(1dip,1dip) 'ignore
ignoring the warning.
 
Upvote 0
Back
Top