Android Question [solved] Change Hint text font size

Jorge M A

Well-Known Member
Licensed User
Longtime User
Are you talking about B4XFloatTextField ?

You can try with:

B4X:
B4XFloatTextField1.HintFont = xui.CreateDefaultBoldFont(20)

or:

B4X:
B4XFloatTextField1.LargeLabelTextSize = 14
B4XFloatTextField1.SmallLabelTextSize = 10
B4XFloatTextField1.Update
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
Are you talking about B4XFloatTextField ?

You can try with:

B4X:
B4XFloatTextField1.HintFont = xui.CreateDefaultBoldFont(20)

or:

B4X:
B4XFloatTextField1.LargeLabelTextSize = 14
B4XFloatTextField1.SmallLabelTextSize = 10
B4XFloatTextField1.Update


Hi Jorge,

NO, its just a "EditText"

Thanks for your time
 
Upvote 0

JMB

Active Member
Licensed User
Longtime User
Hi there. Are you talking about changing the hint text font size in a B4XSearchTemplate?

If so, try this:

B4X:
SearchTemplate.SearchField.LargeLabelTextSize = 12.0

JMB
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
I think you need to change the size of Title Font of this thread! :D:D:D

As far as I know, there is no way to do it with a simple EditText, since the [Hint] underlying object is just a string and is shown with the size defined for the text.

Better switch to B4XFloatTextField.
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
I think you need to change the size of Title Font of this thread! :D:D:D

As far as I know, there is no way to do it with a simple EditText, since the [Hint] underlying object is just a string and is shown with the size defined for the text.

Better switch to B4XFloatTextField.

Thank you... I'll do :)
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
As far as I know, there is no way to do it with a simple EditText, since the [Hint] underlying object is just a string and is shown with the size defined for the text.
No, you can set any character sequence to the hint text using CSBuilder.

Hi,

I need to change the hint text font size

Thanks for your time
Sorry for the wrong answer. I read it incorrectly. You can change the hint text size as below.
B4X:
Dim jo As JavaObject = edittext
Dim csb As CSBuilder
jo.RunMethod("setHint",Array(csb.Initialize.Size(30).Append("Test ").PopAll.Size(20).Append("hint").PopAll))
Screenshot_20191124-140903__01.jpg
 
Last edited:
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
you can set any character sequence to the hint text
Thank you, Brandsum. This was not in doubt. I've even placed Fontawesome Icons.
there is no way to do it with a simple EditText
That's just what I meant. EditTex does not have an exposed native method for resizing the Hint.
I assumed it could be done via Java, which I ignore from "J" to "A". :(

Thank you for your useful code!
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
Thank You @LucaMs!

Based on that answer, using pure B4A, we can use the TextChanged event.

B4X:
Sub Globals
    Private EditText1 As EditText
    Private Size As Float
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    Size=EditText1.TextSize       'Original Size Defined In Designer
    SetHintSize(EditText1)
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
    If (Old.Trim="") <> (New.Trim="") Then
        SetHintSize(EditText1)
    End If
End Sub

Sub SetHintSize(edt As EditText)
    edt.HintColor=Colors.Red
    edt.TextColor=Colors.Blue
    If edt.Text.Trim()="" Then
        edt.TextSize=Size * .60
    Else
        edt.TextSize=Size
    End If
End Sub
 
Upvote 0
Top