Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void drawMonthDay(DateTime dateTime, int month, int year, CalendarCellStyle calendarCellStyle, Canvas canvas, Paint paint, Context context){
- paint.setTextSize(DisplayUtils.convertDpToPixel(DATE_TEXT_SIZE, context));
- paint.setStrokeWidth(5);
- // тут берется шрифт
- paint.setTypeface(CalendarHelper.sFonts[CalendarHelper.ROBOTO_REGULAR]);
- paint.setColor(calendarCellStyle.getDateColor(context));
- if (dateTime != null){
- if (dateTime.getMonth() == month && dateTime.getYear() == year){
- String day = String.valueOf(dateTime.getDay());
- int textWidth = (int)paint.measureText(day);
- int w = canvas.getWidth();
- int xPos = canvas.getWidth()/2 - textWidth/2;
- int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2));
- canvas.drawText(day, xPos, yPos, paint);
- }
- }
- }
- public static Typeface[] sFonts = new Typeface[4];
- Шрифты грузятся так
- public static void loadFonts(Context context){
- sFonts[ROBOTO_REGULAR] = ResourcesCompat.getFont(context, R.font.roboto_regular);
- sFonts[ROBOTO_LIGHT] = ResourcesCompat.getFont(context, R.font.roboto_light);
- sFonts[ROBOTO_BOLD] = ResourcesCompat.getFont(context, R.font.roboto_bold);
- sFonts[ROBOTO_MEDIUM] = ResourcesCompat.getFont(context, R.font.roboto_medium);
- }
Add Comment
Please, Sign In to add comment