3

I have tried with ScrollView FOCUS_DOWN but not scrolling to the bottom, it scrolls near bottom. It must be done after adding a LinearLayout element.

My code:

LinearLayoutView.addView(txtView);
scroll.addView(LinearLayoutView);   
scroll.fullScroll(ScrollView.FOCUS_DOWN);

Thanks

user222
  • 191
  • 2
  • 17

3 Answers3

2

Fixed using the following code:

scroll.post(new Runnable() {

        @Override
    public void run() {
            scroll.fullScroll(ScrollView.FOCUS_DOWN);
    }
});
user222
  • 191
  • 2
  • 17
1

Have you tried the below code ..

scroll.scrollTo(0, scroll.getBottom());

this may help you..

Hariharan
  • 24,741
  • 6
  • 50
  • 54
0

If you are implementing a message type thing that you want to scroll to the bottom when ever there is something new you can use this:

this.getListView().setStackFromBottom(true);
this.getListView().setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL)

This is for a ListActivity, but just replace this.getListView() with the list view in question

FabianCook
  • 20,269
  • 16
  • 67
  • 115