Creating TimePickerDialog with custom style in Android

萝らか妹 提交于 2019-12-23 12:53:24

问题


I'd like to create a DialogFragment or a Dialog with a TimePicker inside, just like in the following image. The problem is that my application is using the Holo.Light theme and then from there, I'm customizing it, but I can't find anything related to TimePicker.

Is it possible to assign a custom style to a TimePicker? I haven't found anything in the official Android documentation.

The following image is what I got so far, but still the TimePicker isn't in the color I want (it's the same orange as in the separator of the title) even tho in the XML I have it as it follows:

<TimePicker
        android:id="@+id/picker"
        style="@style/Checkmark"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip" />

Any ideas, please? Thanks a lot in advance


回答1:


I use HoloEverywhere https://github.com/Prototik/HoloEverywhere to have native Holo elements in android 2.2 and up. You can style the picker easily if you use this library since it's open source and you get full access to the code.

Probably you don't need the whole library, it might be good to get only the TimePicker elements (beware of the dependency hell)



来源:https://stackoverflow.com/questions/18208082/creating-timepickerdialog-with-custom-style-in-android

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