【发布时间】:2015-03-01 16:23:30
【问题描述】:
我想将自定义字体应用于显示在 ActionBar 上的应用标题。以前我没有使用任何支持库和这个解决方案:
int titleId = getResources().getIdentifier("action_bar_title", "id",
"android");
TextView yourTextView = (TextView) findViewById(titleId);
yourTextView.setTypeface(face);
对我来说效果很好。但是现在我正在使用材料设计 SupportActionBar,这会引发 NullPointerException。那么在使用 AppCompat 时如何改变 ActionBar 字体呢?
【问题讨论】:
-
这个回复我想你能帮忙stackoverflow.com/a/15181195/2778639
-
@user27799 谢谢,这篇文章解决了我的问题。如果有人和我有类似的问题,只需使用链接帖子中的方法,它适用于支持库 v-21。
-
这里有解决方案,[Actionbar 自定义设计。][1] [1]:stackoverflow.com/questions/17966350/…
标签: android android-layout android-actionbar android-actionbar-compat android-fonts