How To Use Custom Font In Android Apps

1. Create an assets fonder in your app’s main directory then copy and paste all .ttf font files which you are going to used inside assets folder.

2. In Mainactivity.javafile Like This Way

ublic class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String customFont = "Carrington.ttf";
        Typeface typeface = Typeface.createFromAsset(getAssets(), customFont);
        TextView textView = (TextView) findViewById(R.id.custom_text);
        TextView textView1 = (TextView) findViewById(R.id.custom_text1);
        textView.setTypeface(typeface);
        textView1.setTypeface(typeface);
    }
}

How To Use Fontawesome In Android Studio

  1. Download Fontawesome Font And Find fontawesome-webfont.ttf .
  2.  Past Font In assets folder inside main folder
  3. Copy Font Awesome Icon Code From Fontawesome Chetcheet Here Is Link
  4. Store Fontawesome Icon Code In String.xml file As A Resorce File
<resources>
    <string name="app_name">FontAwesome Icons In Android Application</string>
    <string name="font_awesome_android_icon"></string>
    <string name="font_awesome_area_chart_icon"></string>
    <string name="font_awesome_cubes_icon"></string>
    <string name="font_awesome_mobile_phone_icon"></string>
</resources>

use Icon Name In Textview Or Anoter As text

  <TextView
        android:id="@+id/font_awesome_android_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:gravity="center_horizontal"
        android:text="@string/taxy"
        android:textColor="#80d204"
        android:textSize="50sp" />

MAin Activity

   TextView fontAwesomeAndroidIcon = (TextView) findViewById(R.id.font_awesome_android_icon);
        Typeface fontawasmoe = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf");
        fontAwesomeAndroidIcon.setTypeface(fontawasmoe);


Published by

Unknown's avatar

Nusrat Faria

I Am A Web Developer And A Android Developer. This Is My Personal Blog So Noted My Work For Helping People .

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.