Skizo-ozᴉʞS ツ
Skizo-ozᴉʞS ツ

Reputation: 20616

ActionBar textColor

I'm trying to change the textColor from my ActionBar doing this :

public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(
                    Html.fromHtml("<font color='fff'>"
                            + mDrawerTitle + "</font>"));

            // calling onPrepareOptionsMenu() to hide action bar icons
            invalidateOptionsMenu();
        }
    };

and :

public void onDrawerClosed(View view) {
            getActionBar().setTitle(
                    Html.fromHtml("<font color='fff'>"
                            + mTitle + "</font>"));

            // calling onPrepareOptionsMenu() to show action bar icons
            invalidateOptionsMenu();
        }

But it doesn't work, I've found that you can modify the style.xml but I don't have anything there, I mean, I only have AppBaseTheme and AppTheme.

Is there any advice that you give you to me?

Upvotes: 0

Views: 79

Answers (1)

throws_exceptions_at_you
throws_exceptions_at_you

Reputation: 1746

Either use a SpannableString in this manner:

    String text = "Your text";
    SpannableString spannableString = new SpannableString(text);
    spannableString.setSpan(new BackgroundColorSpan(Color.parseColor("#ffffff")), 0, text.length(), SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
    getActionBar().setTitle(spannableString);

Or set the attribute android:textColor in the styles.xml file for your action bar.

Upvotes: 1

Related Questions