Android:某些设备上的DatePicker微调器文本颜色为白色
我意识到在某些设备上,我的Android:某些设备上的DatePicker微调器文本颜色为白色,android,datepicker,Android,Datepicker,我意识到在某些设备上,我的日期选择器的微调器不显示,因为文本是白色而不是黑色(应该是黑色的) 荣誉示例5C: 一加五的示例: 我是通过设置黑色背景色来实现的: 我试图改变很多不同的属性,但都没有效果 下面是底层代码: final AlertDialog.Builder datePickerDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialog); final View view = fragment.getAct
日期选择器的微调器不显示,因为文本是白色而不是黑色(应该是黑色的)
荣誉示例5C:
一加五的示例:
我是通过设置黑色背景色来实现的:
我试图改变很多不同的属性,但都没有效果
下面是底层代码:
final AlertDialog.Builder datePickerDialog = new AlertDialog.Builder(getContext(), R.style.AlertDialog);
final View view = fragment.getActivity().getLayoutInflater().inflate(R.layout.views_form_pick_date_dialog_day, null);
final AppCompatTextView datePickerDialogTitle = (AppCompatTextView) view.findViewById(R.id.views_form_pick_date_dialog_title);
final DatePicker datePickerDialogSpinner = (DatePicker) view.findViewById(R.id.views_form_pick_date_dialog_spinner);
datePickerDialogSpinner.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.setView(view);
datePickerDialog.show();
关联的XML布局:
R.layout.views\u form\u pick\u date\u dialog\u day
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.AppCompatTextView style="@style/TextViewBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/style_size_space_medium"
android:background="@color/style_color_red"
android:text="@string/app_name"
android:id="@+id/views_form_pick_date_dialog_title" />
<DatePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/views_form_pick_date_dialog_title"
android:calendarViewShown="false"
android:datePickerMode="spinner"
android:id="@+id/views_form_pick_date_dialog_spinner" />
</RelativeLayout>
感谢您的帮助。只需执行以下操作即可更改datePicker textColor:
<DatePicker
android:id="@+id/start_date_text"
android:layout_width="400dp"
android:layout_height="190dp"
android:datePickerMode="spinner"
android:calendarViewShown="false"
style="@style/MyDatePicker" />
风格
<style name="MyDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:textColorPrimary">@color/Black</item>
</style>
@颜色/黑色
为日期选择器设置样式
<style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/primary</item>
</style>
@颜色/原色
@颜色/原色/深色
@颜色/原色
试试这个
将此作为您的活动样式
<style parent="Theme.AppCompat.Light.NoActionBar" name="MyActivityTheme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:textColor">@color/black</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/black</item>
</style>
@颜色/原色
@颜色/原色暗
@颜色/黑色
@颜色/颜色重音
@颜色/黑色
并在清单中添加其作为活动主题
<activity
android:name="yourActivity"
android:theme="@style/MyActivityTheme"/>
它可能会对您有所帮助。如果可能,请确保您使用的是支持库,以便在所有框架版本上显示相同的界面。您找到了解决方法吗?