开发者

Issue in the Assets folder

开发者 https://www.devze.com 2023-04-06 22:48 出处:网络
I had an issue where a font didnt work and it gave me a FC. So I put the font file into the sdcard, and used CreateFromFile in the typeface and the font worked!

I had an issue where a font didnt work and it gave me a FC. So I put the font file into the sdcard, and used CreateFromFile in the typeface and the font worked!

Here is the code I used for the Assets folder:

        holder.tv_SuraName   =(TextView)convertView.findViewById(R.id.Start_Name);
    holder.tv_SuraName.setTypeface(Typeface.createFromAsset(mContext.getAssets(), "suralist_font.ttf"));

But I changed the code to this and it worked:

            holder.tv_SuraName = (TextView)convertView.findViewById(R.id.Start_Name);
        Typef开发者_开发知识库ace Font = Typeface.createFromFile(new File(Environment.getExternalStorageDirectory()+"/asd.ttf"));

Does this mean I have a problem in the Assets folder? How can I fix this? Thanks


see this

  Typeface font0 = Typeface.createFromAsset(getAssets(),"fonts/AmericanDream.ttf"); 
  tv1.setTypeface(font0);

here fonts (folder in assets) folder containing AmericanDream.ttf file inside. like:assets-->fonts-->AmericanDream.ttf i hope this will help u.


AssetManager assetManager1 = getApplicationContext().getAssets();
Typeface tf1 = Typeface.createFromAsset(assetManager1, "James_Fajardo.ttf");

and used in textview like

urTextView.setTypeface(tf1, Typeface.BOLD);

hope useful for u.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号