Issue in the Assets folder

你说的曾经没有我的故事 提交于 2019-12-24 23:58:04

问题


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);
        Typeface 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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/7537502/issue-in-the-assets-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!