Question

My question is i want to change font of action bar without making custom layout for action bar like implment text view and then apply typeface on that text view because i want to too subtitle bar text so what is solution for it

Was it helpful?

Solution 3

Try following code in onCreate()

int titleId = getResources().getIdentifier("action_bar_title", "id",
            "android");
    TextView txtTitle = (TextView) findViewById(titleId);
    txtTitle.setTextColor(getResources().getColor(R.color.title_color));
    txtTitle.setTypeface((Typeface.createFromAsset(this.getAssets(),"FuturaBoldBT.ttf")));

Hope this helps

OTHER TIPS

You can use SpannableString with a custom TypeFaceSpan (https://stackoverflow.com/a/4826885/1785133) for actionBar title and subtitle.

SpannableString sbTitle = new SpannableString(getTitle());
Typeface typeface = Typeface.createFromAsset(getAssets(), "custom.ttf"); //cache it
sbTitle.setSpan(new CustomTypefaceSpan("custom", typeface), 0, sbTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
getActionBar().setTitle(sbTitle);

You can do something like

SpannableString localSpannableString = new SpannableString("Penguin");
localSpannableString.setSpan(new TypefaceSpan(MainActivity.this, "PreludeFLF-BoldItalic.ttf"), 0, localSpannableString.length(), 33);

ActionBar localActionBar = getSupportActionBar();
localActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#81D2F0")));
localActionBar.setTitle(localSpannableString);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top