Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to change fontFamily of TextView in Android

So I'd prefer to change the android:fontFamily in Android however I don't perceive any pre-characterized text styles in Android. How would I choose one of the pre-characterized ones? I don't actually have to characterize my own TypeFace however all I need is something other than what's expected from what it shows at this moment.

<TextView
android:id="@+id/HeaderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="52dp"
android:gravity="center"
android:text="CallerBlocker"
android:textSize="40dp"
android:fontFamily="Arial"
/>
by

2 Answers

rahul07
If you want it programatically, you could use

label.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);

Where SANS_SERIF you can use:

-DEFAULT
-DEFAULT_BOLD
-MONOSPACE
-SANS_SERIF
-SERIF

And where ITALIC you can use:

-BOLD
-BOLD_ITALIC
-ITALIC
-NORMAL
RoliMishra
This is the way to set the font programmatically:

TextView tv = (TextView) findViewById(R.id.appname);
Typeface face = Typeface.createFromAsset(getAssets(),
"fonts/epimodem.ttf");
tv.setTypeface(face);

Login / Signup to Answer the Question.