4

I intent to change the title bar color and actually it works pretty well.

<style name="CustomTheme.Dark" parent="android:Theme.Black">
    [...]
    <item name="android:windowTitleBackgroundStyle">@style/TitlebarBackground.Dark</item>
</style>

<style name="TitlebarBackground.Dark">
    <item name="android:background">#303031</item>
</style>

I have a PreferenceActivity. I apply a background drawable to the ListView for having a border with rounded corners. And now I want to equalize the title bar color with the border color, so in this case I want the title bar color to be #303030. But as soon as the title bar color has exactly the same as the border color, it becomes clean black #000000:

When I set the title bar color to almost the same as the border color - for example #303031 - everything works fine:

Here's the background drawable which generates the border with rounded corners:

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <stroke
        android:width="4dp"
        android:color="@color/border_color" />

    <solid android:color="@color/bg_color" />

    <padding
        android:bottom="4dp"
        android:left="4dp"
        android:right="4dp" />

    <corners
        android:bottomLeftRadius="4dp"
        android:bottomRightRadius="4dp" />

</shape>

Does anybody have any explanation for this... well... strange behaviour?

edit: What - for some strange reason - works as well is setting the title bar background color programmatically:

View title = ((ListActivity) context).getWindow().findViewById(android.R.id.title);
View titleBar = (View) title.getParent();
titleBar.setBackgroundColor(context.getResources().getColor(R.color.border_color_dark));

That way I can equalize both colors as well. Still, I don't understand why specifying the title bar color in XML does not work. No clue. Very mysterious.

4

0 回答 0