datepicker with different style than activity

隐身守侯 提交于 2019-11-29 00:14:50

I know this is little late but I walked into this topic while I was searching something else about DatePickers.

Add this to the custom theme you are using:

<item name="android:datePickerStyle">@android:style/Widget.DatePicker</item>

This will override the parent theme you are using and result as a different looking DatePicker.

You will need to create the dialog with this custom theme.

Example of my theme:

<style name="CustomTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionButtonStyle">@style/MyActionBarButtonStyle</item>
    <item name="android:actionMenuTextColor">#ffffff</item>
    <item name="android:windowBackground">@drawable/bg</item>
    <item name="android:datePickerStyle">@android:style/Widget.DatePicker</item>
</style>
jinal

Try like this:

style="@android:style/Widget.DatePicker"
Rana.S
DatePickerDialog dateDialog = new DatePickerDialog(getActivity(),
                                                   android.R.style.Theme_Holo_Light_Dialog,
                                                   ondateSet, year, month, day);
dateDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

This is for showing white color light background Date picker Fragment.

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