Android How to adjust layout in Full Screen Mode when softkeyboard is visible

前端 未结 25 1752
后悔当初
后悔当初 2020-11-22 03:56

I have researched a lot to adjust the layout when softkeyboard is active and I have successfully implemented it but the problem comes when I use android:theme=\"@andro

25条回答
  •  [愿得一人]
    2020-11-22 04:46

    Don't use:

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

    because works bad. Instead of that, use:

    fun setFullScreen(fullScreen: Boolean) {
            val decorView = getWindow().getDecorView()
            val uiOptions : Int
            if(fullScreen){
                uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN // this hide statusBar
                toolbar.visibility = View.GONE // if you use toolbar
                tabs.visibility = View.GONE // if you use tabLayout
            } else {
                uiOptions = View.SYSTEM_UI_FLAG_VISIBLE // this show statusBar
                toolbar.visibility = View.VISIBLE
                tabs.visibility = View.VISIBLE
            }
            decorView.setSystemUiVisibility(uiOptions)
        }
    

提交回复
热议问题