android - Canvas won't draw -
i don't it, have other custom views in can draw canvas fine. new views i'm creating don't draw canvas @ all! can't find discernible difference between doing , now, it's still same "canvas.drawline()" calls afterall.
here's example view not draw regardless of try (note background black, white color should show up)
public class testview extends view { public testview(context context) { super(context); } public testview (context context, attributeset attrs) { super(context, attrs); } public void ondraw(canvas canvas){ paint paint = new paint(); paint.setcolor(0xffffff); paint.setstyle(paint.style.stroke); paint.setstrokewidth(4); canvas.drawline(0,0, 500, 500, paint); canvas.drawcircle(0,0, 40, paint); logy.print("drew top:" + gettop() + " left:" + getleft() + " right:" + getright() + " bottom:" + getbottom()); } }
i've looked @ other similar questions, , issue i'm having not others. didn't mispell ondraw, ondraw being called (i can tell via logy, simpler facade debug.log()). please consider before marking duplicate of else.
the dimensions of view when ondraw called 0,0,800,800 (left, top, right, bottom). ondraw called @ least once when activity starts. canvas.drawrgb() flood view color.
this view view in activity, , when put "working" custom view in it's place draws fine. new custom views try drawing don't draw.
the colour drawing has alpha value of 0 (aka transparent), , colour of white. try drawing use paint.setcolor(0xffff3432);
or contrast background -- see if see red line, know working.
then choose colour wish. if white going make sure use 0xffffffff
not 0xffffff
colour format:
0xaarrggbb
where = alpha/transparency, r = red, g = green, b = blue.