This is more "Why?" than "how?" question, since I know a simple workaround. But I would like to know what logic is behind the behavior that I will tell.
I have declaraion style and some ListViews. I want to change the appearance of the separator. I used the 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 surprise, only the height of the separator was applied. I tried specifying a color with an alpha value (# 12345678) and a gradient that is no good. ListViews are declared as follows:
<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, since you can see that nothing can override the style declaration. I can only change the delimiter when I specify it directly in the 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 the chosen topic , I can get around this very easily - I just need to declare android:divider using the custom color attribute for each list.
But why can't I change android:divider in style, just like android:dividerHeight ? Is there a reason for this? I could not find explanations, error messages, or anything like that that would allow me to 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">
source share