Reputation: 381
I have an activity with this style:
<style name="CustomStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">@color/statusbar_bg_color</item>
<item name="android:windowBackground">@color/app_background</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
</style>
It shows dark status bar icons, but when I show a dialog, the icons turn the color to light.
The style of my dialog is:
<style name="CustomStyleDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/round_corner_dialog</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
</style>
What I need to change to keep the icons always dark?
This is my manifest
<activity
android:name=".activities.FirstActivity"
android:screenOrientation="portrait"
android:theme="@style/CustomStyle" />
<activity
android:name=".dialogs.FirstDialog"
android:screenOrientation="portrait"
android:theme="@style/CustomStyleDialog" />
Dialog builders (CustomDatepicker is a class extends DatePickerDialog)
DatePicker
private void showDatePickerDialog(Date starDate, int titleResId) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(starDate);
CustomDatePicker datePickerDialog = new CustomDatePicker(this, this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.setTitle(titleResId);
datePickerDialog.show();
}
Alert
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.delete_title)
.setMessage(getResources().getString(R.string.delete_confirmation))
.show();
Upvotes: 3
Views: 997
Reputation: 2119
This issue was occurring for me, in Android 10 devices specifically.
One way to override it would be to make the dialog parent theme ThemeOverlay.AppCompat.Dark
Note: This will make the text and background of dialog dark, in case you are default color. might want to override them yourself.
Upvotes: 1
Reputation: 2545
I think you need dark icons only, use below example code
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert_dark)
.setTitle(R.string.confirm_title)
.setMessage(R.string.confirm_text)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
replace this android.R.drawable.ic_dialog_alert_dark
with dark icon you want
Upvotes: 2