Android Question B4XFloatTextField padding & RTL

mohsyn

Active Member
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
 

oparra

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

klaus

Expert
Licensed User
Or with the nee As method:
B4X:
B4XFloatTextField1.TextField.As(EditText).Padding = Array As Int (0dip, 0dip, 60dip, 0dip) 'Right margin 10dip
 
Upvote 0

mohsyn

Active Member
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

oparra

Well-Known Member
Licensed 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: 35
  • B4XFloatTextField.zip
    10.7 KB · Views: 29
Upvote 0

mohsyn

Active Member
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

oparra

Well-Known Member
Licensed 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 1

oparra

Well-Known Member
Licensed 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