Android Question Changing font dynamically

MitchBu

Well-Known Member
Licensed User
Longtime User
I would like to enable the user to change font in y app.

I searched the forum to find a way to change font dynamically in an EditText, as opposed to within the Designer, but all I found was an old post of mine dating from 2016, which never receive any reply:
https://www.b4x.com/android/forum/t...yles-for-the-standard-font.72699/#post-462415

The best I could find is below, but it is valid only for a string. And it is not quite clear about Bold and Italic. Although there is an example for Underline, so I will try to experiment.

https://www.b4x.com/android/forum/threads/charsequence-csbuilder-tutorial.76226/#content

But what I would really like to do is to change the typeface for anything that will be typed, just like I would do in the Designer.

Any help will be greatly appreciated :)
 

mangojack

Expert
Licensed User
Longtime User
Slightly confused .. looking at your question here that went unreplied, it would appear you wish to use Roboto-Thin ttf.
https://www.b4x.com/android/forum/t...yles-for-the-standard-font.72699/#post-462415

Yet in another thread you received an answer how to achieve this (albeit a Label) ..
https://www.b4x.com/android/forum/threads/custom-fonts-issues.72610/#post-461725

So above you ask .. "a way to change font dynamically in an EditText"

B4X:
Dim roboto As Typeface
    roboto = Typeface.LoadFromAssets("Roboto-Thin.ttf")
'OR roboto = Typeface.CreateNew(Typeface.LoadFromAssets("Roboto-Thin.ttf"), Typeface.STYLE_ITALIC)
    EditText1.Typeface = roboto


But you also ask ..
I would like to enable the user to change font in y app.
Unsure if there is a Font chooser / dialogue.
You could use this lib https://www.b4x.com/android/forum/threads/customfonts.85264/#content
Then possibly set up some font example labels contained in a panel, to be presented to the user.. unless there is something available.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
Mangojack, I see you have gathered all I need to do what I want to do.

Since 2016, I had even forgotten about that answer.

Thank you so much.
 
Last edited:
Upvote 0
Top