我正在寻找一种可能性来调整android蜂窝应用程序中datepicker小部件的文本颜色。我知道小部件固有的是全局文本颜色,在我的情况下是白色,但是我需要黑色的文本颜色作为日期选择器,因为这里的背景是浅灰色。
有人知道怎么修这个东西吗?
最佳答案
完成IT
是否在应用程序styles.xml中的主题中进行了设置(基本上在所有EditText字段上都设置了样式)
我在/values-v11/中有这个,所以它只影响> HC
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.SelectDate" parent="@android:style/Theme.Holo.NoActionBar">
<item name="android:editTextStyle">@style/Widget.EditText.Black</item>
</style>
<style name="Widget.EditText.Black" parent="@android:style/Widget.EditText">
<item name="android:textColor">@color/black</item>
</style>
</resources>
然后在我的AndroidManifest中,对于使用DatePicker的Activity:
<activity
android:name=".ui.phone.SelectDateActivity"
android:label="Date Selection"
android:screenOrientation="portrait"
android:theme="@style/Theme.SelectDate" />
而已!
我的工作:
我通过检查DatePicker源得出了这个结论:
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/date_picker.xml
那告诉我DatePicker使用了NumberPicker
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/number_picker.xml
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/number_picker_with_selector_wheel.xml
NumberPicker使用EditText
因此,您可以设置EditText的样式
android : how to change the style of edit text?
如果您在此文件中搜索“editText”,您将看到可以在一个Activity中的所有edittext字段上设置样式!
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml
您覆盖此项目:
<item name="editTextStyle">@android:style/Widget.EditText</item>