I want to change my toolbar text size and gravity. I create style in styles.xml
like this:
<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
<item name="android:color">@color/colorHighlight</item>
<item name="android:gravity">center</item>
</style>
and I set titleTextAppearance
, everything here looks perfect but it didn't worked. My custom toolbar:
<?xml version="1.0" encoding="utf-8"?>
<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="?attr/actionBarSize"
android:background="#009688"
android:titleTextAppearance="@style/Toolbar.TitleText"
android:paddingTop="0dp"
app:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
What is wrong with my toolbar?
my toolbar
try using
app:titleTextAppearance="@style/Toolbar.TitleText"
instead of
android:titleTextAppearance="@style/Toolbar.TitleText"
as shown here
For centering gravity refer to this question and this question
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