Search code examples
androidtitlebar

Android - Make a custom titlebar that uses the device's current titlebar theme


I'm trying to make a custom titlebar for my first Android application.

While I can find lots on the web about how to make them so you can change colours etc, I want my titlebar to look the same as the "standard" titlebar, but with a button that I can configure. This means copying the device's currently active themes to be able to style it in exactly the same way.

Not all devices simply use a gradient in the titlebar style, so adding a gradient (as suggested in other SO questions) doesn't really make sense.

Does anyone have any pointers how to read the style information?


Solution

  • try to extend an existing theme e.g. create your own style which can ofcourse extend from existing from an existing theme. change the windowNoTitle to true.

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
      <style name="noTitleBarStyle" parent="android:Theme.Black">
      <item name="android:windowNoTitle">true</item>
      <item name="android:windowBackground">@color/darkGrey</item>   
      <item name="android:colorForeground">#ff3333</item> 
      </style></resources>
    

    or try to do it runtime as discussed here Android - change custom title view at run time

    I hope this helps.