Android DatePicker styling

百般思念 提交于 2019-12-25 07:49:06

问题


Trying desperately to style my DatePicker according to numerous SO threads without any luck. Can't figure out why. My problem is that the current and selected dates are invisible due to them having the same color as the DatePicker background.

DatePicker:

<DatePicker
    android:id="@+id/DatePicker"
    style="@style/date_picker_theme"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:calendarViewShown="false"
    android:descendantFocusability="blocksDescendants"
    android:endYear="2100"
    android:startYear="1900" /> 

Style:

<style name="date_picker_theme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <!-- what do I need to add here in order to style the selected and current date? -->
</style>

Nothing I add in the <style> tag (appart from background) affects anything in the DatePicker.


回答1:


I'm posting this as an answer because I found out what was blocking my DatePicker styling and my question therefore became of quite a different character.

The reason I couldn't affect the DatePicker styling was that my theme.xml file contained <item name="colorControlActivated">@color/white</item> resulting a white selected-date background in the DatePicker and actually also on some other elements in the app such as some progress spinners.

I've tried overriding this in the date_picker_theme style:

<style name="date_picker_theme">
    <item name="colorControlActivated">@color/green</item>
</style>

..but nothing happens, so I'll post a dedicated question about that.

Update

New question posted (and answered) here: Android - Overriding theme.xml styling



来源:https://stackoverflow.com/questions/41464562/android-datepicker-styling

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