Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

android - How can I override TimePicker to change text color

My view has a white background, and it has to stay that way. I have a TimePicker on that white background.Everything is woking fine with android 2.3.3 but android 4.0.3 has a new timePicker style. The numbers have a very bright color. It is very hard to see them on the white background, and I didn't find a direct way to change the textColor. I don't want to change the background because it would look not so good.

Is there any way to override this and set the color of the numbers to black?

Sincerly, Wolfen

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Take a look at the android source for styles.xml

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

You then set a style on your activity/timepicker it looks like you could do something like this:

<style name="MyTimePicker" parent="@android:style/Widget.TimePicker">
    <item name="android:textColor">#000000</item>
</style>

or maybe (3.0 and above only)

<style name="MyHoloTimePicker" parent="@android:style/Widget.Holo.TimePicker">
    <item name="android:textColor">#000000</item>
</style>

Then your xml would be:

<TimePicker
 style="@style/MyHoloTimePicker"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...