Question

I have created an android app that simply creates a TableLayout, TableRow and Textview to play with the onClickLiustener.

All the code works and is assigned a default message of "Click here". When the person clicks the text it changes to "A click was detected" and when clicked again returns to the first.

Everything works well but I noticed that the bounds of the TextView increases when given a longer message but doesn't return when given the shorter message again and the TextView responds to the onclick in areas beyond the text.

I have tried setting the layout params of the textView to wrap_content but the control is not visible after doing this.

Is there a way to set the dimensions of the TextView to autosize?

It is just an app to learn android sdk, there is no effect I'm trying to achieve.

Était-ce utile?

La solution

There is a known bug with TextViews not shrinking again after the font size is decreased. This fixes that problem:

youTextView.setText(youTextView.getText(),TextView.BufferType.SPANNABLE); //workaround for Android bug #17343 and #22493
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top