B4J Question B4XFloatTextField Font

Discussion in 'B4J Questions' started by Abdou1283, Apr 17, 2019.

  1. Abdou1283

    Abdou1283 Member Licensed 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 ???
     

    Attached Files:

    • 2.png
      2.png
      File size:
      5 KB
      Views:
      20
    • 1.png
      1.png
      File size:
      6.2 KB
      Views:
      19
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.

    1st Try code is correct. You need to call myTextField.Update after you make those changes.
     
  3. Abdou1283

    Abdou1283 Member Licensed User

    Ok Erel . i will try. thank you so much.
     
  4. Abdou1283

    Abdou1283 Member Licensed User

    HI EREL, i have tried your code, but it doesn't work

    this is my code
    Code:
    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
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Please create a small project and upload it.
     
  6. Abdou1283

    Abdou1283 Member Licensed User

    There is
     

    Attached Files:

  7. Erel

    Erel Administrator Staff Member Licensed User

    Works fine here, after I've changed the font file in the code to the correct file:
    [​IMG]

    Code:
    txtSearch.TextField.Font=xui.CreateFont(fx.LoadFont(File.DirAssets,"myfont.ttf",20),20)
     
  8. Abdou1283

    Abdou1283 Member Licensed User

    Ok Erel. i will try this. great thanks.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice