Is it possible to add padding at the end of an edittext?
My edittexts look like torn pieces of paper and I'd like to add a pushpin (PNG image) near the right edge, but it currently covers the text, so that's why I'm wondering about padding or something. I don't think limiting the number characters would work because that would vary too much between different devices. Thanks.
You can set the padding of any view with this code:
B4X:
Sub SetPadding(v As View, Left As Int, Top As Int, Right As Int, Bottom As Int)
Dim jo As JavaObject = v
jo.RunMethod("setPadding", Array As Object(Left, Top, Right, Bottom))
End Sub
Thank you.
I padded the edittexts on the right edge the same width as an enabled, but transparent, label, and have the labels' click event change the position a pushpin to match. Looks and feels quite nice.
Try this .. requires reference to JavaObject library.
B4X:
Sub DoPadding
For i = 0 To Activity.NumberOfViews - 1
If Activity.GetView(i) Is Button Then
Dim b As Button
b = Activity.GetView(i)
Dim jo As JavaObject = b
jo.RunMethod("setPadding", Array As Object(0, 0, 0, 10))
End If
Next
End Sub
A slightly better routine that handles all views including nested views:
B4X:
For Each v As View in Activity.GetAllViewsRecursive
If v Is Button Then
Dim jo As JavaObject = v
jo.RunMethod("setPadding", ArrayAsObject(0, 0, 0, 10dip))
End If
Next