-2

In my app you can change the theme from Light to Dark and vice versa. What this is doing setting the theme to either Theme.AppCompat.Light.DarkActionBar or Theme.AppCompat and finishing and starting the activity for the layout to load again.

enter image description here

I want to be able to change the color of those three purple lines dividing the settings to the same color of another view in the layout (for example the text). When I switch to dark theme, I want the lines color to change to the exact same color of the text and vice versa for when I switch to light theme. Light theme => dark lines, Dark theme => light lines. I need to be able to do this programatically to whatever the text color is because it is a different shade in different API levels. This is why setting the colors to hard coded values won't work.

nicoqueijo
  • 872
  • 2
  • 11
  • 28

1 Answers1

1

You could redefine the dark and light themes for the android:divider item by adding the following line to both the theme styles.

 <item name="android:divider">your_color</item>

An example of dark theme style would be:

<style name="MyDesign" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">yourcolor</item>
<item name="colorPrimary">yourcolor</item>
<item name="colorAccent">yourcolor</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
<item name="android:divider">yourcolor</item>
<item name="android:windowBackground">@color/window_background</item>
</style>
Abhi
  • 3,431
  • 1
  • 17
  • 35