java - onDraw Method not Called? -
i creating custom view ondraw method never being called. tried doing - setwillnotdraw(false) still doesn't work. in fact, doesn't work after calling invalidate() . here's code - public class box extends view { public box (context context) { super (context); init(); } private void init() { // initialize paint object paint = new paint(); paint.setstyle(paint.style.fill); paint.setcolor(mboxcolor); setmeasureddimension(200, 200); } @override protected void ondraw(canvas canvas) { super.ondraw(canvas); canvas.drawrect(100, 100, 200, 200, paint); } } my activity code - box box = new box(this); please help in mainactivity.java use setcontentview(box);