October 2017
Intermediate to advanced
294 pages
6h 49m
English
In the previous example, we used the setFillColor() method to set the fill color of the custom view, but suppose we will have many other parameters, the code might get a bit messy with all the setters.
Let's create a simple example: instead of having one single background color, we'll have four different colors and we'll draw a gradient on our view:
Let's start by defining the four different colors and their setters as follows:
private int topLeftColor = DEFAULT_FILL_COLOR;
private int bottomLeftColor = DEFAULT_FILL_COLOR;
private int topRightColor = DEFAULT_FILL_COLOR;
private int bottomRightColor = DEFAULT_FILL_COLOR;
private boolean needsUpdate = false;public void setTopLeftColor(int topLeftColor) { this.topLeftColor = ...Read now
Unlock full access