I've read some question related to this topic and tried some code examples. My min API level is 11. Some approaches was to get their id based on the layout source code: dialog layout
I tried to obtain the TextView using simple this code in my DialogFragment:
int titleTextId = getResources().getIdentifier("android:id/alertTitle", null, null);
TextView titleText = (TextView)getDialog().findViewById(titleTextId);
titleText.setTextColor(ContextCompat.getColor(getActivity(), R.color.darkerOrange));
if(titleText != null){
Log.d("DEBUG", "FOUNDED");
}
This is my styles.xml file:
<resources>
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="android:alertDialogTheme">@style/DialogTitleText</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/TitleBarTextColor</item>
<item name="background">@color/white</item>
</style>
<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/darkerOrange</item>
</style>
<style name="DialogTitleText" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="android:windowTitleStyle">@style/DialogTitleStyle</item>
</style>
<style name="DialogTitleStyle" parent="@style/DialogTitleText">
<item name="android:textColorPrimary">@color/darkOrange</item>
</style>
<style name="SplashScreen" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
<style name="TabLayoutTextSize" parent="TextAppearance.Design.Tab">
<item name="android:textSize">20dp</item>
</style>
My AndroidManifest.xml
<application
...
android:theme="@style/AppTheme">
...
These are visited links:
How to style AlertDialogs like a pro
Android - DialogFragment change title text color
Styling custom dialog fragment not working
Android change toolbar title color to white
Even with these approaches I haven't successfully changed title color. And I want 'to preserve min API to 11. Is this related to this min API?