I have found many posts on stackoverflow but I still cannot solve my problem. Here is my code piece:
public class MyView extends RelativeLayout { Button b1;
You need to call setWillNotDraw(false); in order for your onDraw method to be called:
setWillNotDraw(false);
private void init() { setWillNotDraw(false); ... }