如何更改Android DatePicker对话框的“分隔符”颜色 [英] How to change Android DatePicker Dialog's "Dividers" Colors
本文介绍了如何更改Android DatePicker对话框的“分隔符”颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个自定义对话框,基本上我使用的是DatePickerDialog.THEME_HOLO_DARK,但是我想更改divider颜色和文本颜色。
I'm trying to create a custom dialog, basically I'm using DatePickerDialog.THEME_HOLO_DARK but I want to change the "divider" color and the text color.
我要更改蓝色线条和文字颜色为红色。
I want to change the blue lines and the text color to red.
提前感谢!
编辑:
使用此代码:
<style name="testo" parent="@android:style/Widget.DeviceDefault.DatePicker">
<item name="android:divider">@drawable/dialog_divider</item>
</style>
这是我得到的:
this is what I get:
分隔符的drawable基本上是一条红线。
the drawable for the divider is basically a red line..
推荐答案
请使用以下代码
这里,对话框是DatePickerDialog的对象。
Here, dialog is an object of DatePickerDialog.
int dividerId = dialog.getContext().getResources().getIdentifier
("android:id/titleDivider", null, null);
View divider = dialog.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(R.color.red));
int textViewId = dialog.getContext().getResources().getIdentifier
("android:id/alertTitle", null, null);
TextView tv = (TextView) dialog.findViewById(textViewId);
tv.setTextColor(getResources().getColor(R.color.red));
这篇关于如何更改Android DatePicker对话框的“分隔符”颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文