How to customize TimePicker in material design android?

后端 未结 2 1245
时光取名叫无心
时光取名叫无心 2020-12-29 11:12

I am unable to change the selector color and other parts of the TimePicker. So far, I can change header color and background but I am unable to change the innercircle and th

2条回答
  •  Happy的楠姐
    2020-12-29 11:52

    Basic mode

    All you have to do is set your accent color in your Activity's theme:

    #3333cc
    

    This will set all the colors for you so you wouldn't mess up the styling.

    (This also means that you shouldn't set values like amPmBackgroundColor on your TimePicker directly, let Android do the things for you.)

    Advanced mode

    If you want to specify all the possible values separately, do the following:

    First define this in your Activity's theme:

    @style/Theme.MyTheme.TimePicker
    

    Then create the appropriate style:

    
    

    Note that numbersInnerTextColor is only available from API level 23 and other styles (e.g. headerTextColor) can't be set (or at least I couldn't make it work).

    I'd advise against using the "advanced" mode as the TimePicker should have the same colors as the containing Activity and doing otherwise might impact your UX in a bad way.

提交回复
热议问题