Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I change toolbar textsize?

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

like image 959
whatwasmynickname Avatar asked Mar 20 '16 23:03

whatwasmynickname


1 Answers

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

like image 170
Shreyans Avatar answered Sep 28 '22 02:09

Shreyans