Android Question B4XFloatTextField HintLabelLargeOffsetX/Y

fbritop

Active Member
Licensed User
Longtime User
I have a B4XFloatTextField with multiline, about 150dip height. The hint is just fine when I start typing. But when there is no text, it aligns in the middle.

I fave found out that there is no option for "HintLabelLargeOffsetY", but only "HintLabelLargeOffsetX". Is there any alternative way to achieve this?

Startup position of hint with no text:
1593638920739.png


Position after start typing which is correct:
1593638963359.png


Thanks
FBP
 

Mahares

Expert
Licensed User
Longtime User
s there any alternative way to achieve this?
I think there is if you want to modify the B4XFloatTextField class module in the XUI Views library :
Here is what you should try, although I did not have a chance to confirm:
1. Make a copy of the internal library: XUI Views.b4xlib
2. Change its extension to zip
3. Unzip it somewhere on your computer.
4. You will see: B4XFloatTextField.bas
5. Change its name to: myB4XFloatTextField.bas
6. Edit myB4XFloatTextField.bas by making change to this bold code which currently is showing it in the middle: mBase.Height / 2 - b.Height / 2
7. Use it as your class module in your project and refer to it in your code. Do not save it back to XUI VIews.b4xlib and do not modify: XUI VIews.b4xlib
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Thanks @Mahares

You lead me to another solution, until point #6 (maybe the library should be updated @Erel )

Line 38:
B4X:
Private mNextTextField As myB4XFloatTextField

Line 45:
B4X:
Public HintLabelLargeOffsetX, HintLabelLargeOffsetY, HintLabelSmallOffsetY = 2dip, HintLabelSmallOffsetX = 2dip As Int

Line 52:
B4X:
    If xui.IsB4A Then
        HintLabelLargeOffsetX = 6dip
        HintLabelLargeOffsetY = 6dip
    Else
        HintLabelLargeOffsetX = 12dip
        HintLabelLargeOffsetY = 12dip
    End If

Line 214:
B4X:
    If GoingToLarge Then
        HintImageView.SetLayoutAnimated (AnimationDuration, HintLabelLargeOffsetX, HintLabelLargeOffsetY, b.Width, b.Height)
        LargeLabel = True
    Else
        HintImageView.SetLayoutAnimated(AnimationDuration, HintLabelSmallOffsetX, HintLabelSmallOffsetY, b.Width, b.Height)
        LargeLabel = False
    End If

Line 284:
B4X:
Public Sub getNextField As myB4XFloatTextField
    Return mNextTextField
End Sub

Public Sub setNextField (Field As myB4XFloatTextField)
    If Field.IsInitialized = False Then Return
    #if B4A
    If Multiline = False Then
        If Field <> Me Then
            IME.AddHandleActionEvent(mTextField)
        End If
        Dim et As EditText = mTextField
        et.ForceDoneButton = True
    End If
    #End If
    Dim o As Object = Field
    mNextTextField = o
End Sub

Have not tested in B4I yet....
 
Upvote 0
Top