问题
Why is my spinner jumping while scrolling? I'm simply doing following:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(v.getContext(), layout, textViewId, new ArrayList<String>());
adapter.setDropDownViewResource(layoutDropdown);
adapter.addAll(<DATA>);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(listener);
As long as the dropdown is small, everything works fine but if it gets larger and scrollable, I see that it jumps around while scrolling. Why?
I'm not changing the selection or data while scrolling, so I'm surprised that this happens in such an easy setup. Any ideas how to solve this?
回答1:
I was faced with this.
Problem is anroidx update libs
UPDATE: as Bill Bunting comment "alpha04" is ok now
Resolve by revert version appcompat from "alpha02/alpha03" up to "alpha04"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
or better
implementation 'androidx.appcompat:appcompat:1.0.2' -> for more stable
回答2:
This is a very annoying, but known bug fixed in 1.1.0-alpha04 of appcompat, as per the release notes Fixed AppCompatSpinnerscrolling in dropdown mode
来源:https://stackoverflow.com/questions/48328592/spinner-dropdown-list-is-jumping-while-scrolling