AppCompat Toolbar Font Size Inconsistent in Portrait vs. Landscape [duplicate]

三世轮回 提交于 2020-01-04 02:55:09

问题


I'm using this: https://xisberto.wordpress.com/2014/11/08/how-to-combine-actionbar-and-preferenceactivity-headers-with-appcompat/

The "Settings" font size changes between portrait and landscape. How do I keep it consistent?


回答1:


It is normal, the toolbar height in portrait mode have 56 dp, in landscape 48 dp, the OS resize its height. Take care if you change the title size in landscape because you can put it higher than the toolbar.




回答2:


Need to override toolbar title text size by adding

app:titleTextAppearance

Toolbar XML:

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

Answer taken from here



来源:https://stackoverflow.com/questions/28486858/appcompat-toolbar-font-size-inconsistent-in-portrait-vs-landscape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!