【问题标题】:AppCompat Toolbar Font Size Inconsistent in Portrait vs. Landscape [duplicate]AppCompat 工具栏字体大小在纵向与横向中不一致 [重复]
【发布时间】:2015-02-12 20:11:35
【问题描述】:

我正在使用这个:https://xisberto.wordpress.com/2014/11/08/how-to-combine-actionbar-and-preferenceactivity-headers-with-appcompat/

“设置”字体大小在纵向和横向之间变化。如何保持一致?

【问题讨论】:

  • 我认为无法更改。

标签: android android-toolbar


【解决方案1】:

正常,竖屏模式下工具栏高度为56 dp,横屏模式下为48 dp,操作系统调整其高度。在横向更改标题大小时要小心,因为您可以将其放在高于工具栏的位置。

【讨论】:

【解决方案2】:

需要通过添加覆盖工具栏标题文本大小

app:titleTextAppearance

工具栏 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" />

工具栏样式:

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

答案来自here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 2017-02-21
    • 1970-01-01
    • 2011-02-12
    • 2011-07-01
    • 1970-01-01
    相关资源
    最近更新 更多