Last active
August 19, 2019 14:23
-
-
Save davidelp68/6f39cebfa2605572f850e6635765e10c to your computer and use it in GitHub Desktop.
Andorid Studio - FullScreen nel file MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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