I want to change the size of text in Toolbar
. Because in my application, Toolbar
text has different sizes both for landscape and portrait mode.
Is it possible to change the text size of text in 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.
In method 1 Just go to the activity_main. xml file and add a TextView in the toolbar widget with the font-family attribute. The complete code for the activity_main. xml file is given below.
You can click on Fonts and choose the font that you want. First click on the Settings on the top right of the firefox screen, it should look like a gear. Once you click on that, click on General, which should also looked like a gear on the left side of the firefox screen.
Use app:titleTextAppearance
:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:id="@+id/toolbar" app:titleTextAppearance="@style/Toolbar.TitleText" />
and override the default title size in a custom style:
<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title"> <item name="android:textSize">18sp</item> </style>
Result:
for example this your toolbar
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:gravity="center" android:minHeight="?attr/actionBarSize" app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
you can simple add this view this
app:titleTextAppearance="@style/yourstyle"
style.xml
<style name="yourstyle" parent="@style/Base.TextAppearance.AppCompat.Title"> <item name="android:textSize">20sp</item> </style>
like that...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With