android - It seems that Paint.measureText() function is not correct for all languages -
i have implemented ellipsize text function works correct english strings. when applied languages deutch strings not truncated properly. after debuugging came conclusion measuretext not workning properly. here code:
for (int = 0; < valuecount; i++) { textwidth = mselectorwheelpaint.measuretext(moriginalvalues[i]); if (textwidth > maxstringwidth) { float diff = textwidth - maxstringwidth; int numletterstosubstract = math.round(diff / oneletterwidth); int length = moriginalvalues[i].length(); mdisplayedvalues[i] = moriginalvalues[i].substring(0, (length - 1) - (numletterstosubstract + 3)); if (!customlocaleutil.isrtl()) { mdisplayedvalues[i] = string.format("%s...", mdisplayedvalues[i]); } else { mdisplayedvalues[i] = string.format("...%s", mdisplayedvalues[i]); } } else { mdisplayedvalues[i] = moriginalvalues[i]; }
Comments
Post a Comment