Closed ArunVicky001 closed 5 years ago
In my case I have two different calendar when I click the first calendar the months name and selected date colour should be blue and when I click the second calendar the months name and selected date colour should be displayed in orange colour.
I have checked your library below two lines are responsible for the months name and selected date colour, also i have prepared two different drawable file showing the colours
dayBackgroundResId = a.getResourceId(R.styleable.CalendarPickerView_tsquare_dayBackground, R.drawable.calendar_bg_selector); titleTextColor = a.getColor(R.styleable.CalendarPickerView_tsquare_titleTextColor, res.getColor(R.color.dateTimeRangePickerTitleTextColor));
So I have created the separate method for call this CalendarPickerView
CalendarPickerView(Context context, AttributeSet attrs)
during the runtime I am passing the boolean value based on the value different colour has been assigned to the dayBackgroundResId
and titleTextColor
like below,
`public CalendarPickerView(Context context, AttributeSet attrs) { super(context, attrs); attributeSet = attrs;
Resources res = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CalendarPickerView);
final int bg = a.getColor(R.styleable.CalendarPickerView_android_background,
res.getColor(R.color.calendar_bg));
dividerColor = a.getColor(R.styleable.CalendarPickerView_tsquare_dividerColor,
res.getColor(R.color.calendar_divider));
dayTextColorResId = a.getResourceId(R.styleable.CalendarPickerView_tsquare_dayTextColor,
R.drawable.day_text_color);
CalendarTheme calendarTheme = new CalendarTheme();
if (calendarTheme.isFromCalendar()) {
Log.d("WATCH_APP", "-----> true");
// TODO: Date Selected Colour change
dayBackgroundResId = a.getResourceId(R.styleable.CalendarPickerView_tsquare_dayBackground,
R.drawable.calendar_bg_selector);
// TODO: Month Title Colour change
titleTextColor = a.getColor(R.styleable.CalendarPickerView_tsquare_titleTextColor,
res.getColor(R.color.lineBlue));
}
else {
Log.d("WATCH_APP", "-----> false");
// TODO: Date Selected Colour change
dayBackgroundResId = a.getResourceId(R.styleable.CalendarPickerView_tsquare_dayBackground,
R.drawable.calendar_bg_selector_orange);
// TODO: Month Title Colour change
titleTextColor = a.getColor(R.styleable.CalendarPickerView_tsquare_titleTextColor,
res.getColor(R.color.darkyellow));
}
displayHeader = a.getBoolean(R.styleable.CalendarPickerView_tsquare_displayHeader, true);
headerTextColor = a.getColor(R.styleable.CalendarPickerView_tsquare_headerTextColor,
res.getColor(R.color.dateTimeRangePickerHeaderTextColor));
if (colourCode == "blue") {
Log.d("colour code", "Colour code is blue");
}
else {
Log.d("colour code", "Colour code is not blue");
}
a.recycle();
adapter = new MonthAdapter();
setDivider(null);
setDividerHeight(0);
setBackgroundColor(bg);
setCacheColorHint(bg);
timeZone = TimeZone.getDefault();
locale = Locale.getDefault();
if (isInEditMode()) {
Calendar nextYear = Calendar.getInstance(timeZone, locale);
nextYear.add(Calendar.YEAR, 1);
init(new Date(), nextYear.getTime()) //
.withSelectedDate(new Date());
}
}`
the method is calling fine in the runtime but the colour is not changing to the month name and selected date.
Could you please tell me how to achieve my requirement ?
Thanks.
Hi Please check the new version of the lib 1.3.0 and you can find the info in ReadMe on how to override the default colors
I want set custom color for selected date, Could you please tell how to do that?