0

I have a custom title bar set up as a Relative Layout. How would I add it to a theme?

Theme:

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

Is there a specific kind of thing I have to add to the theme or do I have to manually add the title bar to every single activity?

Rohit Sharma
  • 1,271
  • 5
  • 19
  • 37
unhappycat
  • 406
  • 1
  • 4
  • 16

1 Answers1

1

You cannot use layouts in style. If you want to reuse certain layouts consider either using Fragments or see <merge> and <include> tags you can use in XML: https://developer.android.com/training/improving-layouts/reusing-layouts.html

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141