0

I need to implement list view that must show selected item in the center of list view.

Is it possible?

The problem is that list view forbid scrolling before top item and after last item. The only workaround here I found is to add several dummy header and bottom items and use setSelectionFromTop() method for right positioning.

Is there any other better way?

Thanks

Artem
  • 229
  • 6
  • 13

2 Answers2

2

You could use a circular ListView Check this thread on how to implement it

and use smoothScrollToPosition to bring your particular view to the center.

Community
  • 1
  • 1
Pramod
  • 5,150
  • 3
  • 45
  • 46
1

You shouldn't need to add multiple dummy list items. Just extend your Adapter and use a single blank dummy list item that you can programmatically adjust the size of based on the screen resolution of the device.

SBerg413
  • 14,515
  • 6
  • 62
  • 88
  • Yep - the same thing, height adjusting will be needed in both cases and it's not trivial since when adapter gets new view, this view is not laid out yet and it needs to be adjusted in list view class. – Artem Sep 04 '11 at 18:22
  • Unfortunately, I do not think there is a way to do what you're looking to do without implementing a customized Adapter. Sorry I couldn't be of more help. – SBerg413 Sep 04 '11 at 18:34