I use immersive-sticky mode to hide the navigation bar and action bar:
@TargetApi(19)
private void setImmersiveMode() {
if (Build.VERSION.SDK_INT >= 1
For everyone who, like me, will start rewriting solution pasted by @Quinn from Kotlin to Java and later they will find out that on the linked git repo is the solution in Java also, I am pasting it here:
import android.widget.ListPopupWindow;
import android.widget.PopupWindow;
import android.widget.Spinner;
public static void avoidSpinnerDropdownFocus(Spinner spinner) {
try {
Field listPopupField = Spinner.class.getDeclaredField("mPopup");
listPopupField.setAccessible(true);
Object listPopup = listPopupField.get(spinner);
if (listPopup instanceof ListPopupWindow) {
Field popupField = ListPopupWindow.class.getDeclaredField("mPopup");
popupField.setAccessible(true);
Object popup = popupField.get((ListPopupWindow) listPopup);
if (popup instanceof PopupWindow) {
((PopupWindow) popup).setFocusable(false);
}
}
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}