Drawing line numbers with background in Custom android Edittext -


i have created custom edittext class draws line numbers next on left of every line. works fine want set background of line numbers grey , achieve this:

what want like

in ondraw method draw numbers tried draw thick line gets drawn on line numbers no matter put it, before call draws line numbers or after. here code

protected void ondraw(canvas canvas) {     int baseline = getbaseline();      (int = 0; < getlinecount(); i++) {         //line still gets drawn on text         canvas.drawtext("" + (i + 1), rect.left, baseline, paint);         canvas.drawline(rect.left,baseline,rect.right,rect.top,fill);         canvas.drawtext("" + (i + 1), rect.left, baseline, paint);          baseline += getlineheight();      }      super.ondraw(canvas); } 

any suggestions how make line appear in background?

thanks

try draw line @ width of line number. before loop:

paint linepaint = new paint(getpaint()); // copy original paint linepaint.setargb(255, 200, 200, 200); // grey color string strcount = string.valueof(getlinecount());  float[] symbolwidths = new float[strcount.length()]; linepaint.gettextwidths(strcount, symbolwidths);  float strokewidth = 0; (float width : symbolwidths)     strokewidth += width; strokewidth = strokewidth *2/*i dnt knw y*/ + strokewidth; linepaint.setstrokewidth(strokewidth); setpadding((int)strokewidth / 2, 0, 0, 0); // text padding  canvas.drawline(rect.left, getlineheight() * getlinecount(), rect.right, rect.top, linepaint); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo