问题
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