android - 更改android中actionbar项目的文本大小

标签 android xml

我想更改操作栏项目的文本大小。 这是我的 style.xml:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionMenuTextAppearance">@style/menu_text</item>
    <!-- Customize your theme here. -->
</style>

<style name="menu_text">
    <item name="android:textSize">20sp</item>
</style>

这适用于 android 5 但在 android 4 上文本大小是默认的并且不会改变。

最佳答案

在我的项目文件夹 res/styles AppTheme 中有如下评论,

<!-- All customizations that are NOT specific to a particular API-level can go here. -->

所以你可以用你的应用程序主题来做到这一点。我已经通过下面的代码完成了,

<style name="Theme.YourTheme" parent="android:style/Theme">
    <item name="android:actionBarStyle">@style/Theme.YourTheme.Styled.ActionBar</item>
</style>

<style name="Theme.YourTheme.Styled.ActionBar">
    <item name="android:titleTextStyle">@style/Theme.Viadeo.Styled.YourTheme.TitleTextStyle</item>
</style>

<style name="Theme.YourTheme.Styled.ActionBar.TitleTextStyle" parent="@android:style/Widget.TextView">
    <item name="android:textSize">12dp</item>
</style>

希望对你有帮助。

关于android - 更改android中actionbar项目的文本大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31869972/

相关文章:

android - 如何在回收站 View 中设置 On Item Click 监听器并将一个 Activity 中来自 JSON 的数据发送到另一个 Activity ?

android - 如何继承不同api版本指定的样式

Android SQLite更新语句

android - 安卓日历

android - 生产包 React Native 上的 "Unhandled JS Exception: t is not a function. (In ' t(c) ', ' t ' is false)"

android - 尝试打开 Android XML 文件时,如何修复 Eclipse 中出现的 nullpointerexception?

sql-server - SQL Server : How do I check if an element attribute of an xml node contains a specific string?

sql-server - 在 SQL Server 中更新 XML 字符串时查询优化?

xml - 是 XPath sum 还是 fn :sum function implemented in PostgreSQL XPath?

XML 解析/解码不返回任何内容