【问题标题】:Change date-picker text color in spinner mode in android?在android的微调器模式下更改日期选择器文本颜色?
【发布时间】:2020-06-25 18:10:44
【问题描述】:

我尝试过使用自定义样式,但它不起作用,它的默认颜色是灰色的,我希望它是白色的,谁能帮帮我? TIA

XML

<DatePicker
    android:id="@+id/user_dob"
    android:hapticFeedbackEnabled="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:calendarViewShown="false"
    style="@style/MyDatePickerStyle"
    android:datePickerMode="spinner"/>

styles   
<style name="MyDatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker" tools:targetApi="lollipop">
    <item name="android:headerBackground">@color/white</item>
    <item name="android:calendarTextColor">@color/white</item>
    <item name="android:dayOfWeekBackground">@color/white</item>
    <item name="android:yearListSelectorColor">@color/white</item>
    <item name="android:datePickerMode">calendar</item>
    <item name="android:minDate">01/01/1970</item>
</style>

【问题讨论】:

    标签: android android-layout android-xml android-datepicker


    【解决方案1】:

    你可以使用:

    <DatePicker
       android:theme="@style/MyDatePicker"
       ..>
    

    与:

    <style name="MyDatePicker" >
        <!-- Text color -->
        <item name="android:textColorPrimary">@color/....</item>
        <!-- Divider color -->
        <item name="colorControlNormal">@color/...</item>
    </style>
    

    【讨论】:

    • 我知道为什么,但它对我不起作用
    猜你喜欢
    • 2016-10-10
    • 2015-05-27
    • 2016-12-07
    • 2021-08-07
    • 2022-11-24
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    相关资源
    最近更新 更多