31

Default color for lines on Android theme Theme.Holo.Dialog are blue. I'd like to know how to change this to any other color. Orange in my case.

I can change text or background etc.. overriding the theme with a custom style.xml

   <style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Dialog" >
        <item name="android:textColor">@color/coloroscuro</item>
        <item name="android:textColorHint">@color/coloroscuro</item>
   </style>

but I don't know which property manages the color of the lines.

I mean the blue lines that the theme has by default like the ones shown on this other question:

How to Android Holo Theme style dialog box buttons

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
butelo
  • 1,653
  • 1
  • 18
  • 29
  • the default blue lines on Theme.Holo.Dialog. I edited the question to clear this point. tx – butelo Apr 07 '12 at 20:14
  • 2
    @butelo I am wanting to do a similar thing. Did you create a custom Dialog in the end? – bencallis Jul 27 '12 at 19:31
  • Nope. I finally gave up trying, sorry. But recently I've found this theme called HoloEverywhere https://github.com/ChristopheVersieux/HoloEverywhere I think that can be useful if you can modify it at your own will – butelo Jul 29 '12 at 09:27
  • 1
    Never give up! Never surrender! Well, I wanna know too :-( They should have a variant of holo with each of the bold colors from the design guide swatches: http://developer.android.com/design/style/color.html – Geeks On Hugs Aug 05 '12 at 16:26
  • Someone with rep to spare throw a bounty on this please :-( – Geeks On Hugs Aug 05 '12 at 16:27
  • @AnthonyTanas that is not possible, see answer below. You have to create your own. – Paranoid Android Dec 06 '12 at 14:28

3 Answers3

24

Just dug around in the source for you - unfortunately the Divider line in the dialog layouts is a view with a hard coded color background that doesn't reference any themes:

<View android:id="@+id/titleDividerTop"
  android:layout_width="match_parent"
  android:layout_height="2dip"
  android:visibility="gone"
  android:background="@android:color/holo_blue_light" />

So if you want to change the color you'll have to layout your own, custom, dialog box. to make it easier, it wouldn't hurt to just copy from the android source base and customize it to your needs, but you might also get a lot more than you need.

JRaymond
  • 11,625
  • 5
  • 37
  • 40
18

There is a library which does exactly what you need - easy styling of dialogs in Holo theme:

https://github.com/inmite/android-styled-dialogs

David Vávra
  • 18,446
  • 7
  • 48
  • 56
2

one trick is using dialog with no title bar, hence android not draw the line, then adding title and the line yourself in dialog`s layout xml file! for example:

<style name="myDialogStyle" parent="android:style/Theme.Holo.Dialog">
    <item name="android:windowNoTitle">true</item>
</style>

in manifest use:

    <activity
        android:name=".Activity.Mydialog"
        android:theme="@style/myDialogStyle" >
    </activity>

and in your Mydialog layout define title and line yourself with your desired color and style!

cheers!

Navid
  • 901
  • 9
  • 20