Working on a client\'s app that is using immersive mode to hide the navigation bar and status bar on every activity using the following code:
int currentApiV
I think that is not possible. Here
Flutter: How to show onscreen keyboard without android's bottom navigation bar on focusing a textfield?
is stated clearly and my experience seems to confirm it.
the following code placed in an activity
private var appVisibility:Int = ( View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_LOW_PROFILE
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
window.decorView.systemUiVisibility = appVisibility
}
override fun onResume() {
super.onResume()
updateUI()
}
fun updateUI() {
val decorView = window.decorView
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
decorView.systemUiVisibility = appVisibility
}
}
}
correctly hides the nav bar always (when you swipe from the bottom of the screen nav bar appears for a couple of seconds and then disappears) but when keyboard is on. I also tried to open keyboard programmatically and then hide the nav bar after few seconds, without any success.
private fun toggleIME(){
val imm = applicationContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
val view: EditText? = text
if(view != null && imm != null) {
isKOpen = !isKOpen
if (isKOpen) {
view.requestFocus()
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED)
handler.postDelayed(Runnable { // execute after XXXms
updateUI()
window.decorView.systemUiVisibility = appVisibility
}, 5000)
}
else {
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
}
}
I hope to be missing something. I would need that for a custom keyboard I'm developing (where I have to implement the back button)