Hi All,
On the question of scaling text between devices.
I have Klaus's code snippet for finding the best text size and works well. As all views use the same size font I use this code to find the text size for label1 and use it to set the text size of the other views.
I also use code [posted by either Erel or Klaus] to set the padding of views. This code uses Java Objects in a loop, I would like to use something similar to set the text size rather than the long list I am currently using.
The code below is what I am aiming for but can't find information on the "MethodName" or "Parameters" required.
Any guidance greatfully appreciated.
Regards Roger
On the question of scaling text between devices.
I have Klaus's code snippet for finding the best text size and works well. As all views use the same size font I use this code to find the text size for label1 and use it to set the text size of the other views.
I also use code [posted by either Erel or Klaus] to set the padding of views. This code uses Java Objects in a loop, I would like to use something similar to set the text size rather than the long list I am currently using.
The code below is what I am aiming for but can't find information on the "MethodName" or "Parameters" required.
B4X:
' Set padding on all views to zero.
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
If v Is EditText Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
If v Is Label Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
End If
Next
'Klaus's code snippet
SetTextSize(Label1, "Label1 Text")
' Set text size to Label1.textsize.
For Each v As View In Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
jo.RunMethod("MethodName",Parameters)
End If
If v Is EditText Then
Dim jo As JavaObject = v
jo.RunMethod("MethodName",Parameters)
End If
If v Is Label Then
Dim jo As JavaObject = v
jo.RunMethod("MethodName",Parameters)
End If
Next
Any guidance greatfully appreciated.
Regards Roger