I have problem with android EditText widget. In code I set width of widget by pixel. But when user focus and try input text, with of editText widget change. How we can solve this ? Please see video to understand my problem. VIDEO
Note: no need minuses. If you some not understand, please ask here, and I provide more details. Thanks.
float[] sizes = calculateMaxWidthAnswer(answer);
this.editTextWidth = sizes[0];
this.editTextHeight = sizes[1];
editText.setWidth((int) editTextWidth);
editText.setHeight((int) editTextHeight);
protected float[] calculateMaxWidthAnswer(String item) {
CustomKeyboardEditText cKE = new CustomKeyboardEditText(getContext(), isDisabledCustomKeyboard);
cKE.setSingleLine(true);
cKE.setTypeface(Typeface.DEFAULT_BOLD);
cKE.setText(item);
Paint mPaint = cKE.getPaint();
Rect bounds = new Rect();
mPaint.getTextBounds(item, 0, item.length(), bounds);
float size = bounds.width() + MathTool.dpToPx(cKE.PADDING_LR * 3);
return new float[]{size, bounds.height()};
}
In CustomKeyboardEditText
widget, any code which can make this trouble.