I am trying to fix drop down list height of spinner using following method.But it doesn't seems to be working on android 5.1.1 and below.
private void setSpinnerDropDownHeight() {
try {
Field popup = Spinner.class.getDeclaredField("mPopup");
popup.setAccessible(true);
// Get private mPopup member variable and try cast to ListPopupWindow
android.widget.ListPopupWindow popupWindow = (android.widget.ListPopupWindow) popup.get(logWorkBinding.depotSpinner);
// Set popupWindow height to 500px
popupWindow.setHeight(700);
} catch (NoClassDefFoundError | ClassCastException | NoSuchFieldException | IllegalAccessException e) {
Log.e("Exception", "setSpinnerDropDownHeight: " + e.getLocalizedMessage());
}
}
Thanks
Aucun commentaire:
Enregistrer un commentaire