zzh12138/FoldText_Java

about english

Closed this issue · 1 comments

in english has some problem you need to change code

in FoldTextView

` while (layout.getPrimaryHorizontal(end - 1) + getTextWidth(mOriginalText.subSequence(end - 1, end).toString()) < x) {

                end++;
   }

`

to

           `float oldTotal = 0;
            while (true) {
                if (end >= mOriginalText.length()) {
                    break;
                }
                float y1 = layout.getPrimaryHorizontal(end - 1);
                String y2text = mOriginalText.subSequence(end - 1, end).toString();
                float y2 = getTextWidth(y2text);
                float total = y1 + y2;
                if (total >= oldTotal) {
                    oldTotal = total;
                } else {
                    total = oldTotal + total;
                    oldTotal = total;
                }
                if (total < x) {
                    end++;
                } else {
                    break;
                }
            }`

because in english if words to long it maybe cause layout.getPrimaryHorizontal(end - 1) start in new lines