更改操作栏标题字体&颜色

时间:2016-12-06 08:42:24

标签: java android fonts android-actionbar

我想改变我的动作栏标题字体&颜色。所以现在我喜欢这样的代码。我也在使用typekit库。我不知道为什么现在不改变 PLZ对我有一些建议

f = open('test.txt', 'r')
for index, line in enumerate(f.readlines()):
     # index represents the index of the line and line the line in the file.

2 个答案:

答案 0 :(得分:0)

您可以使用工具栏。当你有一个工具栏的引用,你想要标题的样式,你可以做这样的事情

TextView textView = (TextView)toolbar.getChildAt(0);
//set the font and font color.  

如果工具栏中有更多子项,您可能需要循环查找要设置样式的子项

答案 1 :(得分:0)

将Theme.AppCompat.Light更改为Theme.AppCompat.Light.DarkActionBar并尝试以下代码

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="AppTheme.MyActionBar"parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="titleTextStyle">@style/MyTitleTextStyle</item>
</style>

<style name="MyTheme.MyActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/colorWhite</item>
    <item name="android:textStyle">normal</item>
</style>