I'm a complete beginner to Android Studio, I'd like to know how to import new fonts(more precisely: Roboto and Pacifico font families)
-
You want font as your App Font or Android studio font? – meditat Jan 17 '18 at 15:59
-
I primarily wanted as an app font – HUHO Jan 17 '18 at 17:18
4 Answers
It's easy.
- Place a TextView.
- In the properties pane, select the font-family dropdown. If it isn't there, find the caret thingy (the > and click on it to expand the text attributes menu) Expand the font-family drop down.
- In the little list, scroll all the way down till you see
more fonts
- This will open up a dialog box where you can search from Google Fonts
- Search for the font you like with the search bar at the top
- Select your font.
- Select the style of the font you like (i.e. bold, normal, italic, etc)
- In the right pane, choose the radio button that says Add font to project
- Click okay. Now your TextView has the font you like!
BONUS: If you would like to style EVERYTHING with text in your application with chosen font, just add <item name="android:fontfamily">@font/fontnamehere</item>
into your styles.xml
file.

- 382
- 3
- 23
-
1That's great thanks! I had to set `
- @font/fontnamehere
` for it to work. – Laurence Cooper Sep 02 '19 at 10:25 -
The shortest and smartest solution! Thanks!! In addition you can observe any fonts before applying from here: https://fonts.google.com/?preview.text=This%20is%20a%20story&preview.text_type=custom – Araz Jun 12 '22 at 10:57
-
So what do I do if I can find the font on Google Fonts (web) but the search within AS does not find it? – ProjectDelta Sep 08 '22 at 13:44
For setting the font of your step there are some simple steps.
1.select File>New>Folder>Assets Folder
2.click finish
3.right click on assets and create a folder called fonts
4.put your font file in assets > fonts
5.then code to change your font(or create a new theme using that font.)
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/anyFont.ttf");
//and then use the typeface for changing the font using `textView.setTypeface(tf)`

- 1,197
- 14
- 33
To use external fonts, first download the font in .tff format Google font- Roboto
Add the font asset folder as shown in the image below
After the font asset folder is created, copy and paste the downloaded .tff font into the "font" folder. (make sure the name is formatted well. )
Reference the font in your theme.xml or any layout using the android:fontFamily="@font/splashfont" property.
This is how you do it in a theme.xml file
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.FishPott" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/color_black_level_1</item>
<item name="colorPrimaryVariant">@color/color_black_level_2</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/color_black_level_1</item>
<item name="colorSecondaryVariant">@color/color_black_level_2</item>
<item name="colorOnSecondary">@color/color_white_level_1</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:fontFamily">@font/robotoregular</item>
</style>
This is how you do it in a textview
<com.google.android.material.textview.MaterialTextView
android:id="@+id/activity_start_fp_MaterialTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:fontFamily="@font/splashfont"
android:gravity="center"
android:text="MyText"
android:textColor="@color/color_black_level_1"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/activity_start_logo_ShapeableImageView" />

- 1,007
- 4
- 16
- 26
If you want to use these font for your android studio ide then download and install the fonts and change android studio code text font.
If you want to use font for your created android application then you have to put all .ttf files inside asset folder of the app. Please google that how to create asset folder and how to use custom font in your created application

- 316
- 4
- 10