B4J Question B4XFloatTextField Font

Abdou1283

Member
Licensed User
Longtime User
HI, i m using the B4XFloatTextField control in my app.
i want to change the font of the hint text and the text of textField.
The hint text Font is changed but not the text.

1st Try
myTextField.TextField.Font=xui.CreateFont(fx.LoadFont(File.DirAssets,"SOME FONT.ttf",20),20) <<NOT WORKING>>
myTextField.HintFont=xui.CreateFont(fx.LoadFont(File.DirAssets,"SOME FONT.ttf",20),20) <<WORKING>>
2nd Try
Dim jo As JavaObject = myTextField.TextField
jo.runMethod("setFont",Array(fx.LoadFont(File.DirAssets,"SOME FONT.ttf",20))) <<NOT WORKING>>
3rd Try
CSSUtils.SetStyleProperty(myTextField.textField,"-fx-font-family","SOME FONT") <<NOT WORKING>>
4thTry
CSSUtils.SetStyleProperty(myTextField,"-fx-font-family","SOME FONT") <<NOT WORKING>>
When i apply the GetAllViewsRecursive method i found this view
(Text) Text[text="", x=0.0, y=38.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=20.0], fontSmoothingType=LCD, fill=0x000000ff]

ANY IDEA TO SOLVE THIS PROBLEM ???
 

Attachments

  • 2.png
    2.png
    5 KB · Views: 349
  • 1.png
    1.png
    6.2 KB · Views: 354

Abdou1283

Member
Licensed User
Longtime User
HI EREL, i have tried your code, but it doesn't work

this is my code
B4X:
Private txtSearch As B4XFloatTextField
Private xui As XUI
Private fx As JFX

''''''myfont1.ttf is a font file stored in assets directory ("Comic Sans Ms" Font)
txtSearch.TextField.Font=xui.CreateFont(fx.LoadFont(File.DirAssets,"myfont1.ttf",20),20)''<<NOT WORKING>>
txtSearch.HintFont=xui.CreateFont(fx.LoadFont(File.DirAssets,"myfont1.ttf",20),20)''<<WORKING>>
txtSearch.Update
 
Upvote 0
Top