Android HoneyComb DatePicker 文本颜色 [英] Android HoneyComb DatePicker Text Color

查看:17
本文介绍了Android HoneyComb DatePicker 文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种可能来调整 android 蜂窝应用程序中日期选择器小部件的文本颜色.我知道小部件固有的全局文本颜色在我的情况下为白色,但我需要日期选择器的黑色文本颜色,因为这里的背景是浅灰色.

I'm searching for a possibilitie to adjust the text color of the datepicker widget in an android honeycomb app. I knew that the widget inherent the global text-color which is white in my case, but i need a black text-color for the datepicker as the background here is light grey.

有人知道如何解决这个问题吗?

Anyone know how to fix this?

推荐答案

DONE IT

在应用程序styles.xml 的主题中做了它(基本上在所有EditText 字段上设置样式)

Did it in a Theme in the application styles.xml (basically set a style on all EditText fields)

我在/values-v11/中有这个,所以它只影响 >HC

I have this in /values-v11/ so it only affects >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:

Then in my AndroidManifest, for the Activity that uses the DatePicker:

      <activity
            android:name=".ui.phone.SelectDateActivity"
            android:label="Date Selection"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.SelectDate" />

就是这样!

我的锻炼:

我通过查看 DatePicker 来源得出了这个结论:

I came to this conclusion by checking the DatePicker source:

https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/date_picker.xml

这向我展示了 DatePicker 使用的 NumberPicker

That showed me the DatePicker used NumberPicker

https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/number_picker.xmlhttps://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/number_picker_with_selector_wheel.xml

NumberPicker 使用 EditText

The NumberPicker uses an EditText

因此您可以设置 EditText 的样式

You can therefore style an EditText

android:如何更改编辑文本的样式?

如果您在此文件中搜索editText",您将看到您可以在一个 Activity 中的所有编辑文本字段上设置样式!

And if you search in this file for "editText" you will see you can set a style on all edittext fields in one Activity!

https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml

您覆盖此项目:

 <item name="editTextStyle">@android:style/Widget.EditText</item>

这篇关于Android HoneyComb DatePicker 文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆