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 overriding onMeasure
and calling setText
. However this does not affect the TextView
contents.
What am I missing?
EDIT: if you think that it should be done in a completely different way - please feel free to suggest
onMeasure()
is usually called during layout phase. Besides as far as I know onMeasure()
is where YOU have to measure your view. It receives 2 values which are the size of the parent of your view which may be constant.
Why don't you just check the length of the text you're setting and if it's too long just replace it with your default one?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With