我有这种风格的活动:
<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>
它显示暗状态栏图标,但是当我显示对话框时,这些图标将颜色变为浅色。
我的对话框的样式是:
<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>
我需要更改以使图标始终保持黑暗?
这是我的清单
<activity
android:name=".activities.FirstActivity"
android:screenOrientation="portrait"
android:theme="@style/CustomStyle" />
<activity
android:name=".dialogs.FirstDialog"
android:screenOrientation="portrait"
android:theme="@style/CustomStyleDialog" />
对话框构建器(CustomDatepicker是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();
}
警报
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.delete_title)
.setMessage(getResources().getString(R.string.delete_confirmation))
.show();
答案 0 :(得分:2)
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
答案 1 :(得分:0)
这个问题正在我身上发生,特别是在Android 10设备中。
一种替代方法是将对话框设为父主题 ThemeOverlay.AppCompat.Dark
注意:如果您是默认颜色,这将使对话框的文本和背景变暗。可能想自己覆盖它们。