vikramkakkar / SublimePicker

A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.
Apache License 2.0
2.31k stars 407 forks source link

Custom attributes for SublimePicker not working #36

Open Flamedek opened 8 years ago

Flamedek commented 8 years ago

I have the widget set up in a dialog, and all seems to work ok. However I can't get any of the colors to change. What I want is to replace all the 'android green' with a custom color. For this I inflate the view from xml with the following layout

<?xml version="1.0" encoding="utf-8"?>
<com.appeaser.sublimepickerlibrary.SublimePicker
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    app:spHeaderBackground="@color/colorPrimaryAlternative"
    app:spHeaderTextColor="#fff"
    app:spCalendarTextColor="@color/sp_primary_text_light"

    app:layout_gravity="center" >

</com.appeaser.sublimepickerlibrary.SublimePicker>

None of the attributes, also ones not shown here, seem to have any effect. Note that if I directly use SublimeDatePicker, the header background does work. But that doesn't seem to work on it's own. Perhaps the attributes just don't get passed on correctly?

vikramkakkar commented 8 years ago

Note that if I directly use SublimeDatePicker, the header background does work. But that doesn't seem to work on it's own.

SublimePicker does not look for spHeaderBackground. That's a job for SublimeDatePicker. SublimePicker can guide SublimeDatePicker by providing spDatePickerStyle:

<?xml version="1.0" encoding="utf-8"?>
<com.appeaser.sublimepickerlibrary.SublimePicker
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:spDatePickerStyle="@style/MyDatePickerStyle"
    app:layout_gravity="center" >

</com.appeaser.sublimepickerlibrary.SublimePicker>

In your res/values/styles.xml, define MyDatePickerStyle:

<style name="MyDatePickerStyle" parent="SublimeDatePickerStyle">
    <item name="spHeaderBackground">@color/colorPrimaryAlternative</item>
    <item name="spHeaderTextColor">#fff</item>
    <item name="spCalendarTextColor">@color/sp_primary_text_light</item>
</style>