【问题标题】:Android DatePicker stylingAndroid DatePicker 样式
【发布时间】:2017-01-04 13:05:18
【问题描述】:

拼命尝试根据众多 SO 线程设置我的 DatePicker 的样式,但没有任何运气。想不通为什么。 我的问题是当前和选定的日期是不可见的,因为它们与 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 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>

我在&lt;style&gt; 标记中添加的任何内容(来自background)都不会影响 DatePicker 中的任何内容。

【问题讨论】:

    标签: android android-datepicker


    【解决方案1】:

    我将其发布为答案,因为我发现是什么阻碍了我的 DatePicker 样式,因此我的问题变得完全不同。

    我无法影响 DatePicker 样式的原因是我的 theme.xml 文件包含 &lt;item name="colorControlActivated"&gt;@color/white&lt;/item&gt; 导致 DatePicker 中的白色选定日期背景,实际上还出现在应用程序中的一些其他元素上,例如一些进度微调器。

    我尝试以date_picker_theme 样式覆盖它:

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

    ..但是什么都没有发生,所以我会发布一个专门的问题。

    更新

    在此处发布(并已回答)新问题: Android - Overriding theme.xml styling

    【讨论】:

      猜你喜欢
      • 2016-05-04
      • 1970-01-01
      • 2013-12-06
      • 1970-01-01
      • 1970-01-01
      • 2013-07-08
      • 2015-07-26
      • 2010-11-21
      • 1970-01-01
      相关资源
      最近更新 更多