简体   繁体   中英

How to keep full screen when click spinner android?

In my android app I use a spinner. App runs in full screen mode. But when I touch spinner to see the dropdown list, navigation bar appear. It disappears only after selecting an item of dropdown list. Can any body tell me how to keep full screen when click spinner? I've tried this code but it doesn't help me http://devmobapps.blogspot.com/2011/09/bug-in-android-or-problem-with-spinner.html

I'm using Lollipop device. Thanks for any suggestion!

Try adding this flag, as suggested in this solution . Adding it right after setContentView(...) worked like a charm for me:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

As FLAG_FULLSCREEN is deprecated starting from API level 30, you can use FLAG_LAYOUT_NO_LIMITS :

You can also call it when touching the spinner

mSpinner.setOnTouchListener((view, motionEvent) -> { 
    getWindow().setFlags(FLAG_LAYOUT_NO_LIMITS, FLAG_LAYOUT_NO_LIMITS);
    return false;
});

You can use this:

List<String> spinnerArray =  new ArrayList<String>();
for(int i = 0; i< 10; i++)
    spinnerArray.add("item " + i);

Spinner spinner = new Spinner(this, Spinner.MODE_DIALOG);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerArray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

I did not try it in Lollipop device, but it should work

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM