How to set the font of a TextView created at runtime?
I created a TextView
Textview tv = new TextView(this);
tv.setTextSize(20);
I can easily change the size, now I’d like to set font style to "Verdana".
How to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To set In-built Font at Run-Time:
First of all, To Change Font-face, a Typeface class is used.
Now,
at Run-Time, to set the font-face, UsesetTypeface(Typeface)from the Java codeat Design-Time, to set the font-face, Useandroid:typeface="serif"For example:
To set Custom font(s) in your Android application
To do this, simply create an assets/ folder in the project root, and put your fonts (in TrueType, or TTF, form) in the assets. You might, for example, create
assets/fonts/and put your TTF files in there: