-1

I am using Custom font in my application using typeface class. when I run my application it crashes and open the .otf file in a tab. Images are linked. Thanx in advance :-)

here is my java code:

TextView text = new TextView(this);
                LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                //params.setMargins(100,100,500,100);
                Typeface tf = Typeface.createFromAsset(getAssets(),"/fonts/AdobeArabic-Regular.otf");
                text.setTypeface(tf);
                text.setPadding(150,100,150,100);
                text.setGravity(Gravity.CENTER_HORIZONTAL);
                text.setTextColor(getResources().getColor(R.color.White));
                //text.setBackgroundResource(R.color.Green);

                text.setLayoutParams(params);

Here is my error window:

Muhammad wajih
  • 53
  • 1
  • 10

1 Answers1

0

Please try with below one.

Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/AdobeArabic-Regular.otf");

You just added extra '/' in front of fonts.

Md Sufi Khan
  • 1,751
  • 1
  • 14
  • 19