/** * 代码描述: * 为String中部分文字设置TTF字体 * 参考资料: * 1 http://blog.csdn.net/lfdfhl/article/details/27372895 * 2 http://blog.csdn.net/lfdfhl/article/details/10898001 */ private void testTypeface() { String str = "32.000000%"; mTextView = (TextView) findViewById(R.id.textView); //Futura Condensed Medium.ttf为assets下的ttf文件 String ttfPath="fonts/Futura Condensed Medium.ttf"; Typeface mTypeface = Typeface.createFromAsset(getAssets(),ttfPath); SpannableString spannableString = new SpannableString(str); spannableString.setSpan(new TypefaceSpan(ttfPath), 1, 7,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mTextView.setTypeface(mTypeface); mTextView.setTextSize(45); mTextView.setText(spannableString); }