Would a listview and listadapter be a better option?
That'd be my recommendation. In particular, ListView
has a so-called "transcript mode" which can be used to automatically scroll to the bottom as you add new entries to, say, an ArrayAdapter
. The big benefit over ScrollView
-- besides dealing with the "transcript mode" -- is the view recycling, so a lot of updates do not chew up a lot of heap space in your app.
In a ListFragment
, you would execute something like this to enable transcript mode:
getListView().setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
probably (though not necessarily) from wherever you set up your ListAdapter
.
If your adapter is an ArrayAdapter<SomethingFun>
, you can just call add()
on the ArrayAdapter
to append new models, and they will automatically show up at the bottom of the ListView
. In "normal" transcript mode, the user will see the new entries, unless they have scrolled up to view some history, in which case the scroll position is left alone. IOW, what you normally see in a chat-style app.