Change the font type only in the title of the Activity

0

Cordial greeting, In my styles.xml file I have managed to change the title of my second activity with title_activity_options, as well as the color of the bar:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">#f40808</item>
        <item name="colorPrimaryDark">#ff0101</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="ActionBarTitleTextStyle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:text">@string/title_activity_options</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

What I have not been able to do is change that type of font that I have in assets \ font \ milton.ttf.

Someone could tell me how to do it and in which part the suggested code should be placed. I'm still very new.

Thanks in advance.

    
asked by user2683734 02.03.2017 в 05:31
source

1 answer

2

This is the best I could find for you, I think that is what you are looking for

SpannableString s = new SpannableString("My Title");
    s.setSpan(new TypefaceSpan(this, "MyTypeface.otf"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Update the action bar title with the TypefaceSpan instance
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(s);

This is the web where did I get it from?

    
answered by 02.03.2017 / 08:13
source