I am following the answer on this link to span one item of listview at a time on screen. It is working for me but the scrolling and the animation by which item moves up and fits to screen are not working smooth.
I searched and found the method setSelectionFromTop is causing this.
But if i use smoothScrollToPosition then my requirement to fit one item on screen i not fulfilled.
Please help me on this.What shoud I do in order to achieve both
- Fit one item of listview at a time on screen
- Scrolling should work smooth
First, to fit only one item on the screen at a time, you need to set the height of each item to match the height of the ListView.
public View getView(int position, View convertView, ViewGroup parent) {
...
int totalHeight = listView.getHeight();
int rowHeight = totalHeight / getCount();
// Set the row height for each of the rows
...
With only one item showing at a time, where you use setSelectionFromTop() or smoothScrollToPosition(), it will end up with the same result. So you can use smoothScrollToPosition() now.
Another way to do it is to try setting the selection.
listView.setSelection(position)
listView.setSelectionAfterHeaderView()
setSelectionAfterHeaderView will scroll the ListView to the right position.
Hope this helps.