Skip to content

Instantly share code, notes, and snippets.

@Bradleycorn
Created January 22, 2019 02:55
Show Gist options
  • Save Bradleycorn/20ae379495ac9228cfc45f7fc2a4bf11 to your computer and use it in GitHub Desktop.
Save Bradleycorn/20ae379495ac9228cfc45f7fc2a4bf11 to your computer and use it in GitHub Desktop.
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
val isLandscape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE
if (isLandscape) {
supportActionBar?.hide()
supportActionBar?.setDisplayShowTitleEnabled(false)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
} else { // turn OFF full screen
supportActionBar?.show()
supportActionBar?.setDisplayShowTitleEnabled(true)
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment