Android 工具栏:横向模式下的小标题文本

2024-05-03

我正在 Android 上测试新的 Toolbar 和 AppCompat 主题,但遇到了问题。我的工具栏标题文本在纵向模式下看起来是正常大小的,但在横向模式下它变得相当小,尽管我没有在代码中执行任何操作来更改标题的文本大小。以下是屏幕截图:

活动_main.xml:

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.techfunmyanmar.jujaka.ui.MainActivity">

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

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- As the main content view, the view below consumes the entire
             space available using match_parent in both dimensions. -->
        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <!-- android:layout_gravity="start" tells DrawerLayout to treat
             this as a sliding drawer on the left side for left-to-right
             languages and on the right side for right-to-left languages.
             If you're not building against API 17 or higher, use
             android:layout_gravity="left" instead. -->
        <!-- The drawer is given a fixed width in dp and extends the full height of
             the container. -->
        <fragment
            android:id="@+id/navigation_drawer"
            android:name="com.techfunmyanmar.jujaka.ui.NavigationDrawerFragment"
            android:layout_width="@dimen/navigation_drawer_width"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            tools:layout="@layout/fragment_navigation_drawer" />
    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

样式.xml:

<resources>
    <!-- Base application theme. -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowActionBar">false</item>

        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>

    </style>

    <!-- Main application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">

    </style>

    <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">true</item>
    </style>
</resources>

我尝试设置android:titleTextAppearance工具栏的样式,但未应用样式。然后我意识到我正在使用 AppCompat 主题,所以我使用app:titleTextAppearance现在正在应用该样式。看起来横向的小字母是内置的问题AppCompat.Toolbar.Title样式本身,所以我覆盖它以手动设置字体大小。最终代码:

工具栏 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 工具栏:横向模式下的小标题文本 的相关文章

随机推荐

  • QObject:无法为位于不同线程中的父级创建子级

    我在 Windows 7 Ultimate 下使用 Qt 4 6 0 32 位 考虑以下QThread 界面 class ResultThread public QThread Q OBJECT QString post data QNet
  • numpy append_field 给出具有 2d 形状的新字段的形状错误

    我有一个结构化的numpy数组 我想使用recfunctions库http pyopengl sourceforge net pydoc numpy lib recfunctions html http pyopengl sourcefor
  • VB.NET 中的 IndexOf 与字符串数组

    如何在以下代码中找到字符串数组中项目的索引 Dim arrayofitems as String Dim itemindex as UInteger itemindex arrayofitems IndexOf item test Dim
  • WCF 中枚举的 DataContract

    我有一个通过 Net 项目中的 WCF 服务使用的枚举 现在我想添加另一个枚举 其指定方式与第一个枚举相同 但第二个没有在 Reference cs 中注册 因此无法被使用 WCF 服务的项目识别 当我读到如果复制粘贴枚举成员时 会有一个自
  • UITableView:popViewController 并将行索引保留到父控制器中?

    我有以下配置 一个视图控制器父控制器包含一个TableView父表带有自定义单元格 每个单元格显示 2 个标签 一个视图控制器子控制器包含一个TableView子表 当用户单击controllerParent的某个单元格时 会显示此视图 c
  • 在反应中将索引从一个函数传递到另一个函数

    我有一个项目列表 单击删除按钮后该项目将被删除 我知道执行此操作的步骤 但我不知道如何将密钥传递到 dlt item 范围 http jsfiddle net 3Ley7uac 1 http jsfiddle net 3Ley7uac 1
  • stm32中如何在同一个回调函数中从不同的uart获取数据

    我使用的是stm32f407控制器 我正在使用 2 个 uart 2 3 我第一次被中断 但第二次我在 uart 2 上被中断 我在 uart3 上没有被中断 下面是我的回调函数 void HAL UART RxCpltCallback U
  • 查找 Java 中的内存使用情况

    以下是我需要解决的场景 我想出了两种解决方案 我需要维护从数据库获取的数据的缓存 以便在 Swing GUI 上显示 每当我的 JVM 内存超过其分配内存的 70 时 我需要警告用户有关过度使用的情况 一旦 JVM 内存使用率超过 80 那
  • 根据 Google BigQuery 中的查询结果创建表

    我们正在使用谷歌大查询 https developers google com bigquery 通过Python API 如何根据查询结果创建一张表 新表或覆盖旧表 我回顾了查询文档 https developers google com
  • 在 Spring boot 中运行时指定 MongoDb 集合名称

    我试图在两个不同的微服务中重用现有的 EmployeeRepository 代码 见下文 以将数据存储在两个不同的集合中 在同一数据库中 Document collection employee public interface Emplo
  • SQL SERVER 字符串中的掩码字符

    如何替换 SQL SERVER 中字符串中 x 和 y 字符之间的字符 例如 如果我有 TEST123456 最后有 TE 56 我不知道字符串有多长 但我知道我需要屏蔽字符串中 x 和 y 之间的字符 你可以使用REPLICATE htt
  • Printf:Java 和 C 实现的差异

    今天我发现我无法使用 将宽度或精度参数传递给 Java 的实现printf 也就是说 以下论证printf在 C 中有效 但在 Java 中无效 d 10 3 d 10 3 0 d 10 3 5f 11 1 0 9 11 f 5 1 0 9
  • 基于 Netsuite 令牌的 API 调用中的身份验证不明确

    我正在尝试使用基于令牌的身份验证对 Netsuite API 进行 SOAP 调用 我有一个从 WDSL 生成的 C 客户端 它正在发送以下请求 已替换机密
  • JQuery 文件上传:在 data.submit() 上发送两个请求

    我正在尝试使用在我的应用程序中上传视频回形针 and jquery 文件上传 rails 我跟着使用回形针和 jquery 上传文件 https 5minutenpause com blog 2013 09 04 multiple file
  • Spark scala - 按数组列分组[重复]

    这个问题在这里已经有答案了 我对 Spark Scala 很陌生 感谢你的帮助 我有一个数据框 val df Seq a a1 Array x1 x2 a b1 Array x1 a c1 Array x2 c c3 Array x2 a
  • 获得列表并集的最快方法 - Python

    有一个 C 比较可以从列表列表中获取列表的并集 找到集合并集的最快方法 https stackoverflow com questions 11362002 the fastest way to find union of sets 还有其
  • 当我启动虚拟机时“VT-x 不可用”[关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我使用 VMWare 软件创建了一个虚拟机 但在启动虚拟机时出现错误 它说 VT x 不可用 00 00 03 916 NAT zone nm mbu
  • iFrame 应用程序。权限请求?

    我想在用户首次单击我的 iFrame Facebook 应用程序时请求权限 问题是我见过的例子迫使用户单击按钮来加载http www facebook com authorize php http www facebook com auth
  • Android:加速度传感器中的z值范围在不同设备上不同

    我想检测设备是否面朝上 不是成角度 而是平放在地面上 在某些面朝上的设备上 z 值将返回 9 10 之间的值 大多数设备 然而 在 Nexus 7 上 对于面朝上 z 值将返回 6 8 之间的值 我的代码是 if z value gt 9
  • Android 工具栏:横向模式下的小标题文本

    我正在 Android 上测试新的 Toolbar 和 AppCompat 主题 但遇到了问题 我的工具栏标题文本在纵向模式下看起来是正常大小的 但在横向模式下它变得相当小 尽管我没有在代码中执行任何操作来更改标题的文本大小 以下是屏幕截图