Android - How do I change the textColor in a TimePicker?

倖福魔咒の 提交于 2019-12-07 00:24:44

问题


I'm using a TimePicker into a LinearLayout with backgroundColor = black, however, I can't see the numbers in the TimePicker, and I need the background color set to black in the layout, how can I change the textColor in the TimePicker? I already tried this with no luck:

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

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

I tried to assign them as styles in the TimePicker, but the Widget.TimePicker and Widget.Holo.TimePicker parent styles are not recognized in Android, I'm using:

android:minSdkVersion="8"

Could you help me out please? thank you!


回答1:


You should use the style in your layout too:

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

Of course you'll have to create two layouts to use both themes (API level less than 11 or greater than 11), or create your style in two different values- folders ("values" and "values-11"; refer to Android documentation).



来源:https://stackoverflow.com/questions/21662544/android-how-do-i-change-the-textcolor-in-a-timepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!