Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8052265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:30:16+00:00 2026-06-05T07:30:16+00:00

Where in res folder should I put my font file (TTF)?

  • 0

Where in res folder should I put my font file (TTF)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:30:16+00:00Added an answer on June 5, 2026 at 7:30 am

    You can create the font in asset folder (i.e asset/fonts/roboto.ttf).

    Then, create an appropriate class for your TextView:

    // RobotoFont class
    package com.my.font;
    public class RobotoFont  extends TextView {
        public RobotoFont(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
        public RobotoFont(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public RobotoFont(Context context) {
            super(context);
        }
        public void setTypeface(Typeface tf, int style) {
            if (style == Typeface.BOLD) {
                super.setTypeface(Typeface.createFromAsset(getContext().getAssets(),    "fonts/Roboto-Bold.ttf"));
            }
            else if(style == Typeface.ITALIC)
            {
                super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Italic.ttf"));
            }
            else
            {
                super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/Roboto-Regular.ttf"));
            }
        }
    }
    

    and finally, update your layout:

    //main.xml
    //replace textview with package name com.my.font.RobotoFont
    <com.my.font.RobotoFont
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingBottom="2dip" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could put a text file in folder res\raw of a library project, but
I created an XML file and put it in my res folder. I decided
I've a kept one text file in res/raw folder in eclipse. I am showing
I added some UI elements to the main.xml file in the res\layout folder and
I'm trying to read from a file called quiz_questions.txt in my res/raw folder. The
some1 post the code for accessing .txt file available in my res folder the
I've been having some issues reading an XML file in my 'res' folder and
There's this file in my res/drawable-hdpi folder called Thumbs.db and it has an error
This is one file which is stored in my res folder. I want to
I need to get res folder to compile when I export a executable jar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.