问题
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.
回答1:
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.
回答2:
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 :
- Leave it as is and let the system handle the style of your Dialog
- Set a custom view to your Dialog. Check here : DialogFragment : Using AlertDialog with custom layout
来源:https://stackoverflow.com/questions/15065049/custom-support-dialog-fragment-text-is-the-wrong-color