I have a ScrollView, in it a TextView is created programmatically with text and images, which is taken from a string.xml file. In this way:

spanned = Html.fromHtml(byIdName(getContext(), text), new Html.ImageGetter() { public Drawable getDrawable(String source) { Resources resources = getContext().getResources(); int identifier = resources.getIdentifier(source, "drawable", getContext().getPackageName()); Drawable res = resources.getDrawable(identifier); res.setBounds(0, 0, px, hx); return res; } }, null); 

And if there are more than four pictures, then when the fifth one is on the screen, scrolling (scrolling) starts to slow down unpleasantly. When the fifth (or subsequent) picture goes off the screen, the scrolling is smooth again. With the first four pictures there is no such problem.

I can’t get to the bottom, what’s the matter and how can I fix it?

  • Are you doing this in the main thread? Tried to put it in a separate thread? - Silento
  • Tried, carried in new Thread, the same turns out. - Vladimir

1 answer 1

I don’t remember who, but I read somewhere here that there are such problems with ScrollView and precisely with the addition of pictures, so the choice of implementing a similar task with a list fell on RecycleView and a separate adapter for managing the filling of this list (the brakes disappear). Filling the adapter is best placed on the background process (read, AsyncTask).