我的问题是我想更改操作栏的字体而不为操作栏设置自定义布局,例如implment文本视图,然后在该文本视图上应用字体,因为我想要字幕栏文本,所以它是什么解决方案
答案 0 :(得分:1)
您可以将SpannableString
与自定义TypeFaceSpan(https://stackoverflow.com/a/4826885/1785133)一起用于actionBar标题和副标题。
SpannableString sbTitle = new SpannableString(getTitle());
Typeface typeface = Typeface.createFromAsset(getAssets(), "custom.ttf"); //cache it
sbTitle.setSpan(new CustomTypefaceSpan("custom", typeface), 0, sbTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
getActionBar().setTitle(sbTitle);
答案 1 :(得分:0)
您可以执行类似
的操作SpannableString localSpannableString = new SpannableString("Penguin");
localSpannableString.setSpan(new TypefaceSpan(MainActivity.this, "PreludeFLF-BoldItalic.ttf"), 0, localSpannableString.length(), 33);
ActionBar localActionBar = getSupportActionBar();
localActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#81D2F0")));
localActionBar.setTitle(localSpannableString);
答案 2 :(得分:-1)
在onCreate()
int titleId = getResources().getIdentifier("action_bar_title", "id",
"android");
TextView txtTitle = (TextView) findViewById(titleId);
txtTitle.setTextColor(getResources().getColor(R.color.title_color));
txtTitle.setTypeface((Typeface.createFromAsset(this.getAssets(),"FuturaBoldBT.ttf")));
希望这有帮助