Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Toolbar style

I've added a Toolbar to my Lollipop project. However, I'm having trouble styling the Toolbar. My title in the Toolbar appears to have a bold font, but I'd like it to be italic. Any idea how to achieve this? I've tried playing around with the actionbar-style, no luck.

I've set a style on the Toolbar with app:theme="@style/toolbar" and my @style/toolbar (parent ThemeOverlay.AppCompat.ActionBar) is where I'm playing around with no good results.

like image 648
Kenneth Avatar asked Oct 26 '14 20:10

Kenneth


People also ask

How do I change my toolbar icon back on Android?

Customize Back Button in Action Bar We can easily Customize the Back Button by using the getSupportActionBar() library and setting the drawable file using setHomeAsUpIndicator in the java/kotlin file. actionBar. setHomeAsUpIndicator(R. drawable.

What is the toolbar in Android?

In Android applications, Toolbar is a kind of ViewGroup that can be placed in the XML layouts of an activity. It was introduced by the Google Android team during the release of Android Lollipop(API 21). The Toolbar is basically the advanced successor of the ActionBar.

Where is toolbar in Android phone?

Android Toolbar widget is generally found on the top of the screen. The application title, logo, navigation icon, and the menu bar is displayed inside the toolbar. The toolbar is the material design replacement for the old and now deprecated ActionBar.


1 Answers

This is actually really easy. There's a method on Toolbar called setTitleTextAppearance() that everyone seems to be overlooking. Just define your custom textAppearance in styles.xml, such as:

    <style name="MyTitleTextApperance" parent="@android:style/TextAppearance.Medium">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textSize">20sp</item>
</style>

and then in your code, you just call :

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextAppearance(this, R.style.MyTitleTextApperance);

and voila!

like image 154
jasonhudgins Avatar answered Sep 29 '22 12:09

jasonhudgins