سلام و سپاس خدمت عزیران
با کلی زیر رو کردن اینترنت و سایت مرجع بالاخره روشی پیدا کردم که میتونید طول و عرض lable رو با توجه به متن تنظیم کنید و مقدار اون رو بگیرید .
توی سایت ها بحث شده بود که منفی ۲ بزاریم تنظیم میشه ولی یه مشکل جدی این بود که مثلا اگه شما مقدار طول و عرض رو می خواستید در هر صورت -۲ رو بر می گردوند که با کد زیر مشکل حل شده.
(با کلیک روی دکمه متن تنظیم میشه و طول عرض بدست میاد.)
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: LabelWidthauto
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
Dim lblTest, lblHeight, lblWidth As Label
Dim btnChangeWidthHeight As Button
Dim obj As Reflector
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
lblTest.Text = "Line1" & CRLF & "Line2 looooooooong line" & CRLF & "Line3" & CRLF & "Line4"
lblWidth.Text = "width = " & lblTest.Width
lblHeight.Text = "width = " & lblTest.Height
End Sub
Sub btnChangeWidthHeight_Click
Dim Height, Width As Int
lblTest.Width = -2
lblTest.Height = -2
DoEvents ' needed to update the properties
obj.Target = lblTest
Width = obj.RunMethod("getWidth")
Height = obj.RunMethod("getHeight")
lblWidth.Text = "width = " & Width
lblHeight.Text = "height = " & Height
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub

