Guest User

Untitled

a guest
Jun 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. static void drawMonthDay(DateTime dateTime, int month, int year, CalendarCellStyle calendarCellStyle, Canvas canvas, Paint paint, Context context){
  2. paint.setTextSize(DisplayUtils.convertDpToPixel(DATE_TEXT_SIZE, context));
  3. paint.setStrokeWidth(5);
  4. // тут берется шрифт
  5. paint.setTypeface(CalendarHelper.sFonts[CalendarHelper.ROBOTO_REGULAR]);
  6. paint.setColor(calendarCellStyle.getDateColor(context));
  7. if (dateTime != null){
  8. if (dateTime.getMonth() == month && dateTime.getYear() == year){
  9. String day = String.valueOf(dateTime.getDay());
  10. int textWidth = (int)paint.measureText(day);
  11. int w = canvas.getWidth();
  12. int xPos = canvas.getWidth()/2 - textWidth/2;
  13. int yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2));
  14. canvas.drawText(day, xPos, yPos, paint);
  15. }
  16. }
  17. }
  18.  
  19. public static Typeface[] sFonts = new Typeface[4];
  20.  
  21. Шрифты грузятся так
  22. public static void loadFonts(Context context){
  23. sFonts[ROBOTO_REGULAR] = ResourcesCompat.getFont(context, R.font.roboto_regular);
  24. sFonts[ROBOTO_LIGHT] = ResourcesCompat.getFont(context, R.font.roboto_light);
  25. sFonts[ROBOTO_BOLD] = ResourcesCompat.getFont(context, R.font.roboto_bold);
  26. sFonts[ROBOTO_MEDIUM] = ResourcesCompat.getFont(context, R.font.roboto_medium);
  27. }
Add Comment
Please, Sign In to add comment