Anthony Kim
Anthony Kim

Reputation: 3

Change action bar Title font & color

I wanna change my action bar title font & color. so now im doing like this code. also i'm using typekit library too. i dont know why not change now plz have some advice for me

  <style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorCyanAzure</item>
    <item name="colorPrimaryDark">@color/colorWhite</item>
    <item name="colorAccent">@color/colorMelon</item>
    <item name="android:actionBarStyle">@style/AppTheme.MyActionBar</item>
</style>

<style name="AppTheme.MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:titleTextStyle">@style/MyTheme.MyActionBar.TitleTextStyle</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>

Upvotes: 0

Views: 867

Answers (2)

Krutik
Krutik

Reputation: 732

Change you Theme.AppCompat.Light to Theme.AppCompat.Light.DarkActionBar and tried code as below

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

Upvotes: 1

Samuel Agbede
Samuel Agbede

Reputation: 380

You could use a toolbar. When you have a reference to the toolbar and you want to style the title, you could do something like this

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

If you have more children in the toolbar, you may want to loop through and find the child you want to style

Upvotes: 0

Related Questions