I'm trying to achieve a full-screen application, where the user doesn't have any access to the status- & navigation-bar.
Preferably I would want them to be removed completely, but from what I've read this is not possible unless you root the device
So my question basically is: How do I hide the navigation-bar icons, when I show the pop-up menu?
BEFORE
AFTER
So far, I have tried:
- Calling
hideNavigation()
before & after the pop-up menu is shown - Calling
hideNavigation()
inonCreate(), onResume() & onWindowFocusChanged()
- Requesting focus to another view
- Trying to clear the focus from the drop-down (Failed attempt, didn't really find a way to do this)
- Changing the icon colors, "faking" it would be hidden (Failed attempt, didn't really find a way to do this)
- Using
hideNavigation()
in combination withHandler
(Failed attempt, maybe I didn't do it correctly) - Trying to configure some COSU/KIOSK-mode options (Perhaps there is some way to complete disable the whole navigation-bar? I haven't found a way to hide the back-button yet)
ACTIVITY
class PinCodeActivity, HasTitleBar {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_pin_code)
initTitleBarWith(this)
hideNavigation()
}
override fun onResume() {
super.onResume()
hideNavigation()
}
fun hideNavigation() {
window.decorView.apply {
systemUiVisibility = FLAGS
}
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
hideNavigation()
}
}
const val FLAGS = (View.SYSTEM_UI_FLAG_LOW_PROFILE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
TITLE-BAR
fun HasTitleBar.initTitleBarWith(activity: Activity, resId: Int = R.id.titleBar) {
val langButton = activity.findViewById<View>(resId).findViewById<Button>(R.id.tbLanguageChoiceBtn)
val wrapper = ContextThemeWrapper(activity, R.style.MyPopupMenu)
val popupMenu = PopUpLanguageMenu(wrapper, langButton)
langButton.setOnClickListener {
activity.hideNavigation()
popupMenu.showMenu()
activity.hideNavigation()
}
}
POP-UP MENU
class PopUpLanguageMenu constructor(context: Context, view: View) : PopupMenu(context, view) {
private var popupHelper: MenuPopupHelper
init {
val popUpMenu = PopupMenu(context, view).apply {
inflate(R.menu.menu_language_dropdown)
}
popupHelper = MenuPopupHelper(context, popUpMenu.menu as MenuBuilder, view)
popupHelper.run {
gravity = Gravity.END
setForceShowIcon(true)
}
}
fun showMenu() {
popupHelper.show()
}
}
EXPECTED RESULT: Navigation-bar & it's icons are hidden, after the pop-up menu is shown, the icons are still HIDDEN
ACTUAL RESULT: Navigation-bar & it's icons are hidden, after the pop-up menu is shown, the icons are SHOWN