Other Problem with Wrap_content

sotik

Member
Licensed User
Longtime User
Hi all, i'm testing the wrap_content with the next code:


Dim lbl1 As Label
Dim lbl2 As Label
lbl1.Initialize("")
lbl2.Initialize("")

lbl1.Text = "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wsssssssssssssssssssssssssdrfhssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wsssssssssssssssssssssssssdrfhssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF & "wssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" & CRLF
Dim cnv As Canvas
cnv.Initialize(Activity)

Dim he As Int
lbl1.TextSize = 12dip
lbl1.TextColor = Colors.Yellow
he = cnv.MeasureStringHeight(lbl1.Text,Typeface.DEFAULT,12dip)
'ToastMessageShow(he,True)
Activity.AddView(lbl1,50dip,50dip,200dip,-2)
Dim hei As Int
hei = hei + 50dip + lbl1.Height
lbl2.Text = "holaaa"
lbl2.TextColor = Colors.Red
lbl2.TextSize = 12dip
Dim r As Reflector
r.Target = lbl1
Dim a As Int
DoEvents
a = r.RunMethod("getHeight")
ToastMessageShow(a,True)
Activity.AddView(lbl2,50dip,(50dip+a),200dip,40Dip)



i'm seeing the height of the field and i get max 302, that is lower than the real height.
In other program (not for testing) i get max 112 of height, and the height of field should be much more, any idea?
 

sotik

Member
Licensed User
Longtime User
Ok, i have seen that its relevant from Activity.height, but i need one solution to use wrap_content regardless of Activity.height, on my program i have flaps compound of scrollviews where i have a lot of fields, and some fields have a lot of text and they doesn't create with the correct height
 
Upvote 0

sotik

Member
Licensed User
Longtime User
there are some way to know the width of a multiline text?
if i use MeasureStringWidth of canvas i get too much size.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What exactly is the problem ?
A multiline text is wraped to the next line if there is no more place in the current line.
So in this case the width is the view width.
If you mean texts lines separated by CRLF the you might split the text in lines and check the longest width.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…