如何在Android中更改DatePicker的样式? [英] How to change the style of a DatePicker in android?

查看:924
本文介绍了如何在Android中更改DatePicker的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android中更改日期/时间选择器对话框的默认颜色,以使其与我的应用主题匹配.我在Google上搜索了解决方案,但是找不到解决方案.

I want to change the default color of the date/time picker dialog in Android, so that it should match my app's theme. I searched for the solution on Google, but I couldn't find a solution.

我正在做的是创建一种新样式:

What I was doing was creating a new style:

  <style name="datepicker" parent="@android:style/Widget.DeviceDefault.DatePicker">
    <!---TODO-->
    <item name="android:focusedMonthDateColor">@android:color/holo_red_dark</item>
</style>

不知道日期选择器对话框中有哪些可用属性.如果有人可以在该链接上发布链接,那就太好了

添加样式后,我以我的主要样式将其命名为

and after adding the style I was calling it in my main style as

 <item name="android:datePickerStyle">@style/datepicker</item>

不幸的是,这根本不适合我.

Unfortunately, this didn't work for me at all.

推荐答案

尝试一下.这是最简单的&最有效的方法

Try this. It's the easiest & most efficient way

<style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/primary</item>
</style>

这篇关于如何在Android中更改DatePicker的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆