EPG basics and animation setup

We'll start by creating a class-extending view. On its onDraw() method we will draw the following parts:

  • The view background
  • The EPG body with all the channels and TV programs
  • A top time bar hinting at the time
  • A vertical line indicating the current time

We'll also need to trigger a redraw cycle if we are animating some variables.

So, let's start with this implementation of the onDraw() method, and let's proceed method by method:

@Override protected void onDraw(Canvas canvas) { animateLogic(); long currentTime = System.currentTimeMillis(); drawBackground(canvas); drawEPGBody(canvas, currentTime, frScrollY); drawTimeBar(canvas, currentTime); drawCurrentTime(canvas, currentTime); if (missingAnimations()) invalidate(); ...

Get Building Android UIs with Custom Views now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.