material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.38k stars 3.07k forks source link

[MaterialDatePicker] Theme override is not applied to Text Fields in Text Entry Mode #966

Closed froriz5 closed 4 years ago

froriz5 commented 4 years ago

Description: Full description of issue here When instantiating a MaterialDatePicker using the Builder, one of the params is a theme override called setTheme(...)

Here, we can modify how to theme the view with different colors.

It looks like this component uses colorPrimary for almost all the theming.

However, it looks like the TextInputLayout used by the Text Entry mode when selecting a date ignores the colorPrimary value passed in the builder.

Current Behavior datePickerCurrentBehavior

In this current behavior, the AppTheme has a colorPrimary set to a white value.

Expected behavior: The override theme's colorPrimary should be used instead of the app theme's colorPrimary attribute.

datePickerExpectedBehavior

Source code: Example style:

<style name="CustomCalendarDatePickerTheme" parent="@style/ThemeOverlay.MaterialComponents.MaterialCalendar">
    <item name="colorPrimary">@color/colorPrimary</item> <!-- #ff364141 -->
</style>

In the code:

val builder = MaterialDatePicker.Builder.dateRangePicker().apply {
     setTitleText("Title")
     setTheme(R.style.CustomCalendarDatePickerTheme)
}.build()

builder.show(supportFragmentManager, "")

Android API version: 10 Q

Material Library version: 1.2.0-alpha04

Device: Pixel 2

p1415604x commented 4 years ago

I am having similar issue. Setting theme with style for

Instead of taking style from the theme given in builder it takes textInputStyle style from application, so it ignores given theme and uses same styling as all other textInputs within application. Meanwhile it takes correct style values given for header, even it is within same style set to the builder.

Android API Version: 9 Material Library Version: 1.3.0-alpha01 Device: LG G5

dsn5ft commented 4 years ago

Thanks for reporting this, I'm looking into it.

alhajsid commented 3 years ago

i am on 1.3.0 version bug is still here

WestFR commented 3 years ago

Same here