Skip to content

Problem with background and text color of buttons #523

@OneManStudioDotSe

Description

@OneManStudioDotSe

Hello and thanks for this very nice library.

I have a strange problem that I could definitely use some help to sort things out.

I am showing a date and time picker which I am theming a bit. My problem is that the 'ok' and 'Cancel' buttons seem to get as both background color and text color the accent color of my theme.

Here are 2 screenshots and the related code:

screen shot 2018-09-10 at 18 52 22

  private void startDatePicker() {
        Calendar now = Calendar.getInstance();
        DatePickerDialog dpd = DatePickerDialog.newInstance(
                this,
                now.get(Calendar.YEAR), // Initial year selection
                now.get(Calendar.MONTH), // Initial month selection
                now.get(Calendar.DAY_OF_MONTH) // Initial day selection
        );

        dpd.dismissOnPause(true);
        dpd.setLocale(Locale.getDefault());
        dpd.setOkText("Nice!");
        dpd.setAccentColor(0xFF46A4C3);
        dpd.setTitle("Which day will it happen?");
        dpd.setThemeDark(false);
        dpd.setVersion(DatePickerDialog.Version.VERSION_2);
        dpd.show(getActivity().getFragmentManager(), "TAG_FOR_DATE_PICKER");
    }

And the time picker:
screen shot 2018-09-10 at 18 52 34

private void startTimePicker() {
        Calendar now = Calendar.getInstance();
        TimePickerDialog tpd = TimePickerDialog.newInstance(
                this,
                now.get(Calendar.HOUR_OF_DAY),
                now.get(Calendar.MINUTE),
                true);

        tpd.dismissOnPause(true);
        tpd.setLocale(Locale.getDefault());
        tpd.setOkText("Nice!");
        tpd.setTitle("Any specific time?");
        tpd.setThemeDark(false);
        tpd.setAccentColor(ContextCompat.getColor(getActivity(), R.color.white));
        tpd.setOkColor(ContextCompat.getColor(getActivity(), R.color.temp_color_2));
        tpd.setVersion(TimePickerDialog.Version.VERSION_2);
        tpd.show(getActivity().getFragmentManager(), "TAG_FOR_TIME_PICKER");
    }

Here is my theme:

<style name="AppTheme" parent="BaseTheme">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBarOverlay">false</item><!-- new -->
        <item name="android:windowBackground">@color/white_alabaster</item><!-- new -->
    </style>

<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorPrimary">@color/blue_picton</item>
        <item name="colorPrimaryDark">@color/blue_cerulean</item>
        <item name="colorAccent">@color/pink_hot</item>
    </style>

And the colors.xml:

 <color name="colorAccent">@color/pink_hot</color>
    <!-- theme colors -->
    <color name="pink_hot">#ff62cb</color>
    <color name="pink_lavender">#fcaae1</color>
    <color name="pink_persian">#f37ecc</color>

I have removed any other library that might have been colliding with the attributes of your library.

So, my question is if you know what is causing this problem or if I can set both the background color and text color of the buttons.

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions