Is possible to change dynamically the size of the text of an EditText when the text is too long and readjust it to fit within the bounds?
Asked
Active
Viewed 126 times
2 Answers
1
I believe you should create a custom TextView. Check out @speedplane soulution : How to adjust text font size to fit textview

Community
- 1
- 1

Behzad Bahmanyar
- 6,195
- 4
- 35
- 41
-
It is something like I want to do... but I want to resize the text inside the editText, not a text View – Gabriele Marcozzi Sep 05 '15 at 10:07
0
EditText editText = (EditText) findViewById(R.id.editText);
editText.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
if (editText.getText().toString().length() > 15)
{
editText.setTextSize(10)
}
});
I've not tested this but that should generally work.
-
But in some devices (with a bigger screen), the editText can containsmore than 15 chars..... instead, smaller screen devices can contain less than 15 chars – Gabriele Marcozzi Sep 04 '15 at 19:35