【问题标题】:Add a title bar to a theme in Android在 Android 中为主题添加标题栏
【发布时间】:2018-03-11 00:31:28
【问题描述】:

我有一个自定义标题栏设置为Relative Layout。如何将其添加到主题中?

主题:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CustomWindowTitleBarBG">
        <item name="android:background">#323331</item>
    </style>

    <style name="TitleBarTheme" parent="android:Theme.DeviceDefault.Light.NoActionBar">
        <item name="android:windowTitleSize">60dip</item>
        <item name="android:windowTitleBackgroundStyle">
            @style/CustomWindowTitleBarBG</item>
    </style>
</resources>

我是否必须向主题添加特定类型的内容,还是必须手动将标题栏添加到每个活动?

【问题讨论】:

标签: android android-theme android-titlebar


【解决方案1】:

您不能在样式中使用布局。如果您想重用某些布局,请考虑使用 Fragments 或查看您可以在 XML 中使用的 &lt;merge&gt;&lt;include&gt; 标签:https://developer.android.com/training/improving-layouts/reusing-layouts.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-27
    • 1970-01-01
    • 2012-08-01
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-10
    相关资源
    最近更新 更多