0

I'm creating a custom EditText to append a suffix to the text with the following code:

public class EditTextWithSuffix extends AppCompatEditText {

    TextPaint textPaint = new TextPaint();
    private String suffix = "ssssss";

    @Override
    public void onDraw(Canvas c) {
        super.onDraw(c);
        int suffixXPosition = (int) textPaint.measureText(getText().toString()) + getPaddingLeft();
        c.drawText(suffix, suffixXPosition, getBaseline(), textPaint);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        textPaint.setColor(getCurrentTextColor());
        textPaint.setTextSize(getTextSize());
        textPaint.setTextAlign(Paint.Align.LEFT);
    }
}

The suffix (ssssss) is correctly shown in input field for Left-to-Right langs such as English but not for RTL layouts (like Arabic or Persian).

Would you please help?

Mahozad
  • 18,032
  • 13
  • 118
  • 133

0 Answers0