There is a TextView
of a certain size and whenever text set to it is too long I\'d like to re-set it to some preset value.
To accomplish this I am overr
You will want to implement Textwatcher
and in the onTextChanged(...)
method, call TextView
's setEms(...) method, which will set the width of the TextView
to the width of (n m's), where n is the input for setEms(...)
.
...
TextView tv = (TextView) findViewById(R.id.my_text_view);
tv.addTextChangedListener(this);
...
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
tv.setEms(count);
}