This is more "Why?" than "How?" question, since I know a simple workaround for the problem. But I'd like to know what logic is behind behavior I'm going to describe.
I've got a style declaraion and some ListViews. I want to change the way divider looks. I used following declaration:
<style name="Theme.MyApp.Dark" parent="@style/Theme.Sherlock">
<item name="android:dividerHeight">4px</item>
<item name="android:divider">#123456</item>
</style>
To my amusement, only the height of the divider was applied. I've tried specifying color with alpha value (#12345678) and gradient drawable, nothing works. ListViews are declared like this:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
So, as you can see there's nothing that could override style declaration. I can change the divider only when I specify it directly in ListView declaration:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:divider="#123456"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Using my newly-acquired skill of specifying colors depending on theme selected, I can work around this very easily - I will just have to declare android:divider
with custom color attribute for every list.
But why I can't change android:divider
in the style, just like the android:dividerHeight
? Is there some reason for that? I couldn't find an explanation, bug report or something similar that would let me understand this behavior.
EDIT: The theme is applied globally, in the Manifest file:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="org.my.app" android:theme="@style/Theme.MyApp.Dark">