Autosizing TextViews in RecyclerView causes text size to decrease

后端 未结 6 836
野趣味
野趣味 2021-02-13 17:24

I am trying to use Autosizing TextViews in a RecyclerView, but when I scroll a few times the text gets so small that it\'s obviously not working properly.

Example of my

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-13 17:35

    Just .setText("") before resetting the text size you want. That ensures that you are not setting the textsize and then immediately autoresizing using the previous text value in the TextView. Like this:

    TextView wordWordTextView = getView().findViewById(R.id.wordWordTextView);
    wordWordTextView.setAlpha(0.0f);
    wordWordTextView.setText("");
    wordWordTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50);
    wordWordTextView.setText(wordStr);
    wordWordTextView.animate().alpha(1.0f).setDuration(250);
    

提交回复
热议问题