I am struggling with the TEXT color change in AppCompat DialogFragments.
My application uses the DARK theme ( Theme.AppCompat.NoActionBar ), but for the dialogs I want to use the LIGHT theme. I use Build Tools, Support Library and compileSdkVersion to 25, it matters.
I can change everything else in the dialog box (title, background, window background) , but not the main and accented text colors that continue to use (white) settings for a dark theme, leaving white text on a white background.
I tried dozens of solutions on similar issues here in SO, for example:
1) Easy: on styles.xml:
<style name="AppTheme" parent="AppBaseTheme"> <item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item> <item name="android:alertDialogTheme">@style/AppCompatAlertDialogStyle</item> </style> <style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="colorPrimary">#ff0000</item> <item name="colorPrimaryDark">#ff0000</item> <item name="colorAccent">#ff0000</item> <item name="android:textColorPrimary">#F040FF</item> <item name="android:textColor">#F040FF</item> </style>
With this solution, the background style and buttons from AppCompat.Light.Dialog.Alert APPLIED, but not the color of the text, as you can see in the screenshot:

2) Manually specifying the AlertDialog creation style:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle); LayoutInflater inflater = getActivity().getLayoutInflater(); View hostView = mHostView = inflater.inflate(layoutId, null);
Same problem. Light background, Light text.
3) Using ContextWrapper:
ContextThemeWrapper ctw = new ContextThemeWrapper(getActivity(), R.style.AppCompatAlertDialogStyle); AlertDialog.Builder builder = new AlertDialog.Builder(ctw);
Nothing :( The same thing happens
4) Handing over instructions of other exotic constants, I came across a lot of posts here in SO, for example
Theme_DeviceDefault_Light_Dialog_Alert THEME_DEVICE_DEFAULT_LIGHT
It was just a desperate attempt, but in any case the text does not change
5) Specifying the style in the fragment, and not in the dialog box
Dialog_Meta newFragment = new Dialog_Meta(); newFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.AppCompatAlertDialogStyle); newFragment.show(fragmentManager, TAG);
I used this solution again in a very old version of the API, I canβt remember what the problem is, but in any case it does not solve the problem :(
Can anyone tell me what's going on?