October 2017
Intermediate to advanced
294 pages
6h 49m
English
Now that we've seen how to modify an already existing View, we'll see a more complex example: how to create our own custom view from scratch!
Let's start by creating an empty class that extends from View:
package com.packt.rrafols.customview;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
public class OwnCustomView extends View {
public OwnCustomView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
}
We will now add the same code as the previous example to draw a red background:
package com.packt.rrafols.customview; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; ...
Read now
Unlock full access