Android Question B4XFloatTextField padding & RTL

epiCode

Active Member
Licensed User
I'm using B4XFloatTextField and having few concerns

1. Padding on right side hides X and Tick symbols
2. When Arabic/Urdu/Persian text is entered in text field it moves the text on Right Side (which it should) but again the text is below X and Tick symbol (which should have ideally moved to left but didn't)
3. The baseline stops at a point defined by padding, however ideally padding is to prevent text from touching the boundary, and when B4XFloatTextField outline is set it looks visually unappealing to have baseline not fill the whole panel.

Can anyone please guide me on how to resolve this ?

full.png
 

TILogistic

Expert
Licensed User
Longtime User
B4A?
B4X:
    Dim edt As EditText = B4XFloatTextField1.TextField
    edt.Padding = Array As Int (0dip, 0dip, 10dip, 0dip) 'Right margin 10dip
 
Upvote 0

epiCode

Active Member
Licensed User
Hey @oparra and @klaus !!!

My concern is not on "how to" get padding done programmatically
My concern is ....

1. How to let X and tick move to left on RTL input ( Not hiding them - moving them)
2. How to let the base bar be shown fully irrespective of padding value

Sorry if it didn't come across very clearly in first post and thanks for responding :)
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
The only thing missing is that the entrance is on the right.

you have that function or api, I think it is with IME.
 

Attachments

  • 1.gif
    1.gif
    46.6 KB · Views: 382
  • B4XFloatTextField.zip
    10.7 KB · Views: 318
Upvote 0

epiCode

Active Member
Licensed User
I just tested the code you shared
(I just added 60 as left padding in second one)

Some observations:
1. Code resets parameters set via Designer (Not an issue- can be corrected)
2. Tick mark is not working only X (cancel) works.
3. After padding the same issues stay:
  • Padding is still covering buttons and text both (while it moves the text when it has focus - the text goes back into hiding beneath the padding)
  • base line is still showing only for unpadded region (my take is that even base line is getting under padding 'element')
1631479748583.png
 
Upvote 0

epiCode

Active Member
Licensed User
I hope this is what you are looking for, or at least it can guide you
I definitely learnt a new method, thanks to you :)

btw, is b4xfloattextfield open source ?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Found enter RTL

FloatTextField.TextField.As(EditText).Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT)

B4X:
Public Sub SetFloatTextField(FloatTextField As B4XFloatTextField)
    FloatTextField.SmallLabelTextSize = 14 'Hint Small
    FloatTextField.LargeLabelTextSize = 16 'Hint Large
    FloatTextField.TextField.TextSize = 16 'Text
   
    Dim TextFontSmall As B4XFont = xui.CreateFont2(FloatTextField.HintFont, FloatTextField.SmallLabelTextSize)
    Dim TextWidthSmall As Int = MeasureTextWidth(FloatTextField.HintText, TextFontSmall)
   
    Dim TextFontLarge As B4XFont = xui.CreateFont2(FloatTextField.HintFont, FloatTextField.LargeLabelTextSize)
    Dim TextWidthLarge As Int = MeasureTextWidth(FloatTextField.HintText, TextFontLarge)
   
    FloatTextField.HintLabelSmallOffsetY =  5 'Inside
    FloatTextField.HintLabelSmallOffsetX = (FloatTextField.TextField.Width - TextWidthSmall) - 5 'Right
    FloatTextField.HintLabelLargeOffsetX = (FloatTextField.TextField.Width - TextWidthLarge) - 5 'Right
    FloatTextField.Update
   
    If FloatTextField.lblV.IsInitialized Then
        FloatTextField.lblV.SetLayoutAnimated(0, 2dip, 0, FloatTextField.lblV.Width, FloatTextField.mBase.Height)
    End If
    If FloatTextField.lblClear.IsInitialized Then
        FloatTextField.lblClear.SetLayoutAnimated(0, FloatTextField.lblV.Width + 4dip, 0, FloatTextField.lblClear.Width, FloatTextField.mBase.Height)
    End If
   
    FloatTextField.TextField.As(EditText).Gravity =  Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT)
   
'    Padding
    If FloatTextField.Text <> "" Then
        FloatTextField.TextField.As(EditText).Padding = Array As Int (60dip, 0dip, 0dip, 0dip)
    Else
        FloatTextField.TextField.As(EditText).Padding = Array As Int (0dip, 0dip, 0dip, 0dip)
    End If

End Sub

1631481787837.png
 
Upvote 2

TILogistic

Expert
Licensed User
Longtime User
I definitely learnt a new method, thanks to you :)

btw, is b4xfloattextfield open source ?
unzip XUI Views.b4xlib. see B4XFloatTextField.bas

 
Upvote 0
Top