12

I am using spinner in scroll view, when I do selection of spinner, scroll view is scrolling to top of screen. Is there any way to prevent this scroll?

Any help is appreciated.

Thanks.

Mitesh Sardhara
  • 234
  • 3
  • 12
  • Were you able to determine the cause of this? I have this occurring now, but not with all spinners. – Mark Freeman Jan 02 '13 at 16:38
  • @Mark : No still did not get any solution. I have one scrollable screen with many spinners, when I select item of one of the spinners at that time screen scrolls to top of screen. Post here if you find any solution. Thanks. – Mitesh Sardhara Jan 05 '13 at 12:30
  • I think you are mis-diagnosing your problem. I have never experienced it and I have numerous scrollable screens with spinners that do not exhibit this behaviour. – gssi Oct 16 '12 at 12:42
  • check my answer on this https://stackoverflow.com/questions/48328592/spinner-dropdown-list-is-jumping-while-scrolling/55214793#55214793 – Hoa Nguyen Mar 18 '19 at 07:35

1 Answers1

5

All

For above my issue I have set one property for scrollview in xml.

android:descendantFocusability="beforeDescendants"

And it has worked for me like a charm.

I have found solution here

Focusable EditText inside ListView

https://stackoverflow.com/a/2680077/1556997

Thanks all for the help.

Community
  • 1
  • 1
Mitesh Sardhara
  • 234
  • 3
  • 12
  • 2
    Hi, i m also facing exact issue, i tried like this in my scroll view but no luck :(. can you please tell how you fixed. I m trying in ICS 4.0 . – Naruto Apr 29 '14 at 18:51
  • Hi, CAA, noppe i was not able to solve this. If we use Actionbarsherlock, its not allowed. I checked with jakewarthon, he also suggested we cant use the internal spinner of actionbarsherlock. so i just thought of keeping default one. Thanks ill check ur answer – Naruto Aug 09 '14 at 18:58
  • 1
    android:descendantFocusability="beforeDescendants" does not work with my ScrollView and I can't find more information to fix this issue ... – Thom Thom Thom Jan 23 '15 at 13:00
  • 1
    Old post, still up to date. I've been stuck with RecyclerView with the same issue - spinner as recyclerview item, change spinner selection causes recyclerview to scroll. This solves the issue. – user1209216 May 22 '19 at 06:31
  • please check this link, related scrollview.setOnTouchListener(), this fixed my issue https://stackoverflow.com/a/8101614/2164477 – Amitabh Sarkar Jun 19 '23 at 06:10