So i have a spinner as you can see in the image
So what i want to do is that i only want to display the first 3 items and rest items should be scroll-able. Any Ideas?
you can adjust you spinner popup menu height like below:
Spinner spinner = (Spinner) findViewById(R.id.spinner);
try {
Field popup = Spinner.class.getDeclaredField("mPopup");
popup.setAccessible(true);
// Get private mPopup member variable and try cast to ListPopupWindow
ListPopupWindow popupWindow = (ListPopupWindow) popup.get(spinner);
popupWindow.setHeight(500);
}
catch (NoClassDefFoundError | ClassCastException | NoSuchFieldException | IllegalAccessException e) {
// silently fail...
}
在xml 中将此属性设置为 spinner :
android:dropDownHeight="100dp"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.