Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change size of title's text on Action Bar?

There is an ActionBar on each Android 4.0 application, and it got a title. I need to make this size less. But I don't understand how I can do it, because ActionBar doesn't provide public methods for it. Remark: I don't want to use custom views.

like image 887
malcoauri Avatar asked Oct 15 '12 13:10

malcoauri


People also ask

How do I change the text size in Android Studio toolbar?

Typeface typeFace = Typeface. createFromAsset(getAssets(), "fonts/font_name. ttf"); Now, get the child item (toolbar title textview) from the existing toolbar, the default toolbar and pass the typeface object we created above.

How do I customize my action bar?

This example demonstrate about how to create a custom action bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.


2 Answers

Actually, you can do what you want to customize the ActionBar. It must be done through the Theme. You can do something like this :

<style name="Theme.YourTheme" parent="android:style/Theme">     <item name="android:actionBarStyle">@style/Theme.YourTheme.Styled.ActionBar</item> </style>  <style name="Theme.YourTheme.Styled.ActionBar">     <item name="android:titleTextStyle">@style/Theme.Viadeo.Styled.YourTheme.TitleTextStyle</item> </style>  <style name="Theme.YourTheme.Styled.ActionBar.TitleTextStyle" parent="@android:style/Widget.TextView">     <item name="android:textSize">12sp</item> </style> 
like image 178
Aurélien Guillard Avatar answered Oct 07 '22 19:10

Aurélien Guillard


You could always do something like this:

ActionBar actionBar = getActionBar(); actionBar.setTitle(Html.fromHtml("<small>YOUR TITLE</small>")); 
like image 33
Matt W Avatar answered Oct 07 '22 18:10

Matt W