android - Using breakText, what value should maxWidth have? -
in current code i'm getting width of screen , using in breaktext maxwidth.
display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); int width = size.x; paint p = new paint(); p.settextsize(60); p.setsubpixeltext(true); endchar = p.breaktext(fulltext, 0, endtext, true, width, null);
this code isn't giving me desired answers, giving more characters needed, guess i'm using maxwidth wrongly. can explain should entered in maxwidth?
remember density of screen , scale factor text on device. should divide screen width in px scaleddensity screen width in sp.
it should that:
display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); displaymetrics metrics = getresources().getdisplaymetrics(); int width = (int)((float)size.x/metrics.scaleddensity); paint p = new paint(); p.settextsize(60); p.setsubpixeltext(true); endchar = p.breaktext(fulltext, 0, endtext, true, width, null);
Comments
Post a Comment