Skip to content

Instantly share code, notes, and snippets.

@davidelp68
Last active August 19, 2019 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidelp68/6f39cebfa2605572f850e6635765e10c to your computer and use it in GitHub Desktop.
Save davidelp68/6f39cebfa2605572f850e6635765e10c to your computer and use it in GitHub Desktop.
Andorid Studio - FullScreen nel file MainActivity.kt
import android.content.res.Configuration
import android.view.WindowManager
//potrebbero esserci altri import
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)
screenOrientation() //chiamata alla funzione screenOrientation in fase di creazione dell'activity
}
override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
screenOrientation()
}
private fun screenOrientation() {
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
//Per abilitare il full screen:
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
}
else if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT)
{
//Per disabilitare il full screen:
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment