DatePickerDialog按钮未显示标签

时间:2018-05-16 22:41:04

标签: java android kotlin

enter image description here

底部的两个按钮不会显示标签。这是我实例化日期选择器new DatePickerDialog(classname.this, date, myCalendar .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();的方式 我正在运行Android Studio 3.2 Canary并且目标sdk为28。

2 个答案:

答案 0 :(得分:0)

<item name="colorAccent">@color/colorAccent</item>中检查styles.xml,按钮文字颜色与colorAccentcolors.xml的值相同。

编辑: -

按照以下方式更新您的风格,它将起作用:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:buttonBarPositiveButtonStyle">@style/DialogButtonStyled</item>
    <item name="android:buttonBarNegativeButtonStyle">@style/DialogButtonStyled</item>
    <item name="android:buttonBarNeutralButtonStyle">@style/DialogButtonStyled</item>
</style>

<style name="DialogButtonStyled" parent="Theme.MaterialComponents.Light">
    <item name="android:textColor">@color/colorWhite</item>
</style>

答案 1 :(得分:0)

您可以使用它来应用材质按钮样式:

 <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:buttonBarPositiveButtonStyle">@style/Widget.MaterialComponents.Button</item>
    <item name="android:buttonBarNegativeButtonStyle">@style/Widget.MaterialComponents.Button.TextButton</item>
    <item name="android:buttonBarNeutralButtonStyle">@style/Widget.MaterialComponents.Button</item>
</style>

结果:materialDatePicker