Reputation: 2367
How can I change the element color in the preference dialog.
I get green:
When I create my own elements, in my own dialog, elements take the color from my colorAccent
value, and I would like to achieve the same in the preferences dialogue:
Upvotes: 1
Views: 719
Reputation: 875
You should create custom style for your dialog. Eg, like here:
<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColor">@color/n1</item>
<item name="android:textColorPrimary">@color/n2</item>
<item name="colorAccent">@color/your_color</item>
</style>
And in your dialog fragment set custom style:
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
....
Context context = new ContextThemeWrapper(getContext(), R.style.AlertDialogStyle);
....
}
Also you can set it from styles:
<style name="AppTheme" parent="BaseAppTheme">
<item name="alertDialogTheme">@style/AlertDialogStyle</item>
....
</style>
Upvotes: 4