It is completely incomprehensible why a spinner behaves this way. Pay attention to the scroll bar. And what Spinner, AppCompatSpinner behave the same.

Example problem

@zTrap, @kizoso, I even found a curious code inside the SDK that I suspect. Inside the android.widget.ListPopupWindow class, the following listener was detected:

private class PopupTouchInterceptor implements OnTouchListener { public boolean onTouch(View v, MotionEvent event) { final int action = event.getAction(); final int x = (int) event.getX(); final int y = (int) event.getY(); if (action == MotionEvent.ACTION_DOWN && mPopup != null && mPopup.isShowing() && (x >= 0 && x < mPopup.getWidth() && y >= 0 && y < mPopup.getHeight())) { mHandler.postDelayed(mResizePopupRunnable, EXPAND_LIST_TIMEOUT); } else if (action == MotionEvent.ACTION_UP) { mHandler.removeCallbacks(mResizePopupRunnable); } return false; } } private class ResizePopupRunnable implements Runnable { public void run() { if (mDropDownList != null && mDropDownList.isAttachedToWindow() && mDropDownList.getCount() > mDropDownList.getChildCount() && mDropDownList.getChildCount() <= mListItemExpandMaximum) { mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); show(); } } } 

It is just very similar to what happens if the number of elements in the spinner is more than what is placed on the screen — the show method is called if you don’t remove your finger in a quarter of a second (EXPAND_LIST_TIMEOUT). But then it is completely incomprehensible to me why and how it works in other projects ...

  • one
    Where is the testing spend? I mean the emulator. Or something in the code can be - Alex Tremasov
  • Emulators, real devices, on one project are repeated on any screens, even if you just add a spinner with a set of rows from the array-string and do not hang any listeners, on another project it does not repeat. Repeats only with 6 or 7 android. - Kirill Vlasov
  • one
    Without a code, one cannot understand anything unambiguously - zTrap pm
  • Add to the question the minimum reproducible example without it is impossible to help you - kizoso
  • @kizoso, @zTrap, the trouble is that all the code is in <androidx.appcompat.widget.AppCompatSpinner android:id="@+id/my_spinner" android:layout_width="wrap_content" android:minWidth=100dp android:entries="@array/spinner_data" /> And it’s not possible to reproduce even on another project. Although on any activations and fragments of the current project is reproduced. - Kirill Vlasov

1 answer 1

In general, I found out with what it was connected, on the version of androidx.appcompat: appcompat: 1.1.0-alpha01 works fine, there is such a bug on more recent ones ... It is strange that I did not notice when I checked on another project that there was a different version of appcompat.