工具栏标题文本大小随方向变化而减小 [英] Toolbar title textsize decreases on orientation change

查看:96
本文介绍了工具栏标题文本大小随方向变化而减小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将方向从纵向更改为横向时,工具栏标题的文本大小会减小,而当我重新更改为纵向时,则会重置.发生这种情况的活动扩展了使用getSupportActionBar()ActionBarActivity.

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().

推荐答案

使用以下解决方案:

<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" />

工具栏样式:

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

这篇关于工具栏标题文本大小随方向变化而减小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆