Android TimePickerDialog styling guide/docs?

前端 未结 2 1130
不知归路
不知归路 2021-02-01 08:36

I\'m trying to style a TimePickerDialog for sdk 21+ (Lollipop). So far I\'ve figured out how to change the default colorscheme in XML:


Then below that, define the timePickerDialogTheme and set the timePickerStyle:


Now you can define most of the styling here..


The important line in the above is:

@style/TextAppearance.TimePickerDialogStyle.TimeLabel

Because if you want to style the text (well, time, actually) in the header you need to define the headerTimeTextAppearance:


Now, if you take a look at the Widget.Material.TimePicker in AOSP styles.xml (ctrl-f 'timepicker' until you find it) you'll notice a bunch of other properties that you should be able to modify:

headerTimeTextAppearance
headerAmPmTextAppearance
headerSelectedTextColor
headerBackground
numbersTextColor
numbersBackgroundColor
amPmTextColor
amPmBackgroundColor
amPmSelectedBackgroundColor
numbersSelectorColor

Most of these work (as long as you prepend 'android:' for each of them) BUT I could not get 'headerSelectedTextColor' to work. I got a compile error saying something like "could not match property bla bla". Also, if you look at my example above, I hardcoded the textSize for the 'headerTimeTextAppearance' property because the '@dimen/timepicker_ampm_label_size' value threw errors.

In short: most of the things are listed above and how to get them working. But not all is clear. So I'd still see that complete documentation/guide :)

提交回复
热议问题