Styling the view

maltaisn edited this page Mar 15, 2018 · 7 revisions

Many attributes are provided to style the view's colors and child views.

Changing an attribute

You can change attribute in your app's styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="recurrencePickerStyle">@style/RecurrencePickerStyleCustom</item>
</style>

<!-- Recurrence picker theme -->
<style name="RecurrencePickerStyleCustom" parent="RecurrencePickerStyle">
    <!-- You can customize the recurrence picker style here -->
    <!-- This line remove the header's background -->
    <item name="rpColorHeaderBackground">@android:color/transparent</item>

    <!-- This line changes the option list check ImageView style -->
    <item name="rpOptionCheckStyle">@style/OptionCheckStyle</item>
</style>

<style name="OptionCheckStyle" parent="RpOptionCheckStyle">
    <!-- Don't forget to specify the parent! -->
    <item name="android:src">@drawable/ic_custom_icon</item>
</style>

Parent style name is always the same as the attribute name but starts with a capital letter. It's important to specify the parent, because the parent style might define some attributes that you don't.

If you are declaring a RecurrencePickerView in a XML layout file, you can also use android:theme on it to set its theme separatedly of other picker views.

Available attributes

General attributes

  • rpColorPickerBackground: background color of the picker
  • rpColorHeaderBackground: background color of the header

Option list attributes

  • rpOptionListTitleStyle: option list header title TextView style
  • rpOptionItemStyle: option list item TextView style
  • rpOptionItemSelectedColor: option list item selected color
  • rpOptionItemUnselectedColor: option list item unselected color
  • rpOptionCheckStyle: option list item check ImageView style
  • rpOptionCheckSize: option list item check width and height

Recurrence creator attributes

  • rpLabelTextAppearance: text appearance used for all labels and EditTexts in the recurrence creator
  • rpPeriodSpinnerStyle: style of the period spinner
  • rpPeriodSpinnerItemStyle: style of a period spinner selected item
  • rpPeriodSpinnerDropdownItemStyle: style of a period spinner dropdown item
  • rpEndSpinnerStyle: style of the end type spinner
  • rpEndSpinnerItemStyle: style of a selected end type spinner selected item
  • rpEndSpinnerDropdownItemStyle: style of a end type spinner dropdown item
  • rpWeekButtonStyle: style of a day of week ToggleButton. Its color can be customized with the other attributes below.
  • rpCancelButtonStyle: style of the cancel button
  • rpDoneButtonStyle: style of the done button

Day of week buttons attributes

  • rpColorWeekButtonChecked: color of the button's background when checked
  • rpColorWeekButtonUnchecked: color of the button's background when unchecked
  • rpColorWeekButtonStroke: color of the button's circle stroke
  • rpColorWeekButtonStrokeWidth: width of the button's circle stroke
  • rpColorWeekButtonTextChecked: color of the button's text when checked
  • rpColorWeekButtonTextUnchecked: color of the button's text when unchecked
  • rpWeekButtonSize: button width and height

String arrays attributes

  • rpPeriodSpinnerItemsText: strings to use for period spinner items
  • rpEndSpinnerItemsText: strings to use for end type spinner items in dropdown
  • rpEndSpinnerItemsTextAbbr: strings to use for end type spinner items when selected (should be shorter)
  • rpWeekButtonsText: strings to use for day of week buttons text
  • rpOptionListNoneText: string to use for "Does not repeat" item in default options list
  • rpOptionListCustomText: string to use for "Custom..." item in default options list

There is no style attributes available for recurrence creator's individual labels and EditTexts, the switch and monthly settings radio buttons. If that could be useful for you, tell me, it isn't hard to add.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.