5

If I put a TextView in a custom dialog box, the text will be black by default.

Unfortunately, the support fragment dialogs backgrounds are dark gray. Black on gray is very hard to read.

I could change the TextView to white or something like android:textColor="?android:attr/textColorPrimaryInverseDisableOnly". But the dialog boxes on the new android (Holo Light) are white. So it will be white on white.

I could use a hack like forcing it to be white on old versions of Android and forcing it to be black on newer versions of Android, but I'd rather find a more elegant solution.

Is there a way to change the TextView to imitate the same text that's normally put on the support DialogFragment? I'm using Action Bar Sherlock, if that matters.

Muz
  • 5,866
  • 3
  • 47
  • 65

2 Answers2

3

Try this

alertDialogBuilder.setInverseBackgroundForced( true )

works fine in my case on pre-Honeycomb devices and newer ones. The title still appears in a darker color but the main text is clearly readable on all devices.

HeyMan
  • 1,529
  • 18
  • 32
  • This question was a long time ago and I can't really remember what I tried to do with it. So it might be a while before I could test this answer :) – Muz Nov 18 '13 at 05:59
  • This works for me. This function inverses the background color on old devices while has no effect on newer devices. – Stephen Cheng Sep 11 '14 at 03:23
0

If you're using ActionBarSherlock, I'm guessing you're supporting old devices as well. Sad thing about it is that old phones won't display any Holo Dialog, only old ugly Dialogs (and on many phones, they'll also be heavily customized by manufacturer). Therefore can't assume your Dialog will be Light.

There's only 2 things you can do :

Community
  • 1
  • 1
ben
  • 1,151
  • 10
  • 20
  • I'm already using a custom dialog. It looks just fine on the boring old compatibility dialogs, but looks wrong on the custom ones. Changing the background is a possibility, but then I'd have to switch all the existing dialogs to have a custom background. – Muz Feb 26 '13 at 03:37