Dear members,
I have a question. It would be very nice if you could help me! There is a Autoscale module on b4x.com but I can't use this in some modules. Also it would be useful to have a second code by hand...
My problem is that sometimes the text is too big and sometimes the textsize is 1, so that you don't see anything...
Now here is my code: (#1)
#2
All code subs get called every time when the text changes
I made a example project: https://www.dropbox.com/s/myvj7zj5do5r9iq/Scale.zip?dl=0
Why it's on Dropbox? So I can update the file if needed!
It would be great if you could help me solving the mistake in my code!
Thanks for reading this entry!
Yours sincerely,
Chris
I have a question. It would be very nice if you could help me! There is a Autoscale module on b4x.com but I can't use this in some modules. Also it would be useful to have a second code by hand...
My problem is that sometimes the text is too big and sometimes the textsize is 1, so that you don't see anything...
Now here is my code: (#1)
B4X:
Sub scalelbl1
Dim bmp As Bitmap
bmp.InitializeMutable(1dip,1dip)
cv.Initialize2(bmp)
Dim size As Float
For size = 2 To 80
If CheckSize(size) Then
Next
size = size - 0.5
If CheckSize(size) Then size = size - 0.5
Label1.TextSize = size
End Sub
Sub CheckSize(size As Float) As Boolean
Return cv.MeasureStringWidth(Label1.Text, Label1.Typeface, size) > Label1.Width OR _
suu.MeasureMultilineTextHeight(Label1, Label1.Text) > Label1.Height
End Sub
#2
B4X:
Do Until cv.MeasureStringWidth("X", Typeface.DEFAULT, size) < 45dip AND suu.MeasureMultilineTextHeight(labelex, "X") < 45dip OR size = 1
size = size -0.5
labelex.TextSize = size
Loop
I made a example project: https://www.dropbox.com/s/myvj7zj5do5r9iq/Scale.zip?dl=0
Why it's on Dropbox? So I can update the file if needed!
It would be great if you could help me solving the mistake in my code!
Thanks for reading this entry!
Yours sincerely,
Chris