Gnanam R
Gnanam R

Reputation: 407

How to bring scroll bar/view in top position?

scrollbar

tableLayout My view data /tableLayout

/scrollbar

I showed the data.. when I m in last row of view, once my UI is updated I want to bring scroll to the top position.

What should be code that I need to be done for this action. Thanks in Advance.

Upvotes: 1

Views: 979

Answers (3)

Vinayak Bevinakatti
Vinayak Bevinakatti

Reputation: 40513

scrollView.fullScroll(ScrollView.FOCUS_UP);

OR

scrollView.scrollTo(0, 0); 

should work

Upvotes: 2

Narendra
Narendra

Reputation: 1868

you may, do like this

int idx = list.getFirstVisiblePosition();
View vfirst = list.getChildAt(0);
int pos = 0;
if (vfirst != null) pos = vfirst.getTop();

//Restore the position
list.setSelectionFromTop(idx, pos);

Upvotes: 0

MrWaqasAhmed
MrWaqasAhmed

Reputation: 1489

call listView.setSelectionAfterHeaderView(); to scroll to top

Upvotes: 0

Related Questions