My custom font is not customizable in a text editor

mEditText = (EditText) getContentView().findViewById( R.id.custom_text );
AssetManager assests=getContext().getBaseContext().getAssets();
Typeface tf = Typeface.createFromAsset(assests, "fonts/DroidSansFallback.ttf");
mEditText.setTypeface(tf);

I am trying to install my own font using the code above. Everything is going well, there is no error, but I can not install my own font on mine EDIT_TEXT. I can not understand what is happening.

0
source share
2 answers
// try this way,hope this will help you...

1. First of all you have create "fonts" directory under "assets" directory and put you custom fonts file on "fonts" directory.

2. now try to apply this code here i used my custom fonts "Helvetica LT 45 Light_0.ttf"

XML
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:gravity="center">

    <EditText
        android:id="@+id/edtCusomFonts"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>

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

        edtCusomFonts = (EditText) findViewById(R.id.edtCusomFonts);
        Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Helvetica LT 45 Light_0.ttf");
        edtCusomFonts.setTypeface(tf);

    }
+1
source

Try

mEditText.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/DroidSansFallback.ttf"));
0
source

All Articles