5

The Toolbar title textsize gets decreased when I change orientation from portrait to landscape and gets reset when I change back to portrait. The activity in which this happens extends ActionBarActivity which uses getSupportActionBar().

NorthCat
  • 9,643
  • 16
  • 47
  • 50
isudansh
  • 370
  • 3
  • 16
  • I think it's a known issue. Asked here http://stackoverflow.com/questions/28486858/appcompat-toolbar-font-size-inconsistent-in-portrait-vs-landscape – Pooja Mar 16 '15 at 09:03
  • @Pooja My other activities don't face this issue. – isudansh Mar 16 '15 at 14:16
  • 1
    That is working as intended. The landscape toolbar is shorter, so the text size is smaller. – alanv Mar 17 '15 at 20:55
  • Possible duplicate of [Android Toolbar: small title text in landscape mode](http://stackoverflow.com/questions/28042331/android-toolbar-small-title-text-in-landscape-mode) – Aristo Michael Apr 19 '16 at 10:45

2 Answers2

4

Use the below solution:

<android.support.v7.widget.Toolbar
        android:id="@+id/main_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:titleTextAppearance="@style/ToolbarTitle"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Toolbar Style:

<style name="ToolbarTitle" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title">
        <item name="android:textSize">20sp</item>
</style>
Smeet
  • 4,036
  • 1
  • 36
  • 47
2

I think this problem exists in android.support.v7.widget.Toolbar. Even I faced the same issue. But to maintain text size consistency I used the following method.

<style name="ToolbarText" parent="@style/TextAppearance.Widget.AppCompat.Toolbar.Title">
        <item name="android:textSize">17sp</item>
</style>

And use this style for toolbar.

<android.support.v7.widget.Toolbar 

    ....
    app:titleTextAppearance="@style/ToolbarText" />
Pooja
  • 2,417
  • 20
  • 39
  • You can resize from code is best, you can't put 17sp,18sp.... 40sp.... in a future your code will deprecated ;) –  Dec 16 '15 at 11:11