How to lock ImageView orientation when rotate screen in Kotlin? simply how to freeze ImageView (as background) when rotate activity?
Trying: I tried to change a image in LinearLayout as background, and use this method but it is not working!!
override fun onConfigurationChanged(newConfig : Configuration) {
super.onConfigurationChanged(newConfig)
val linearLayout = findViewById<LinearLayout>(R.id.linearBg)
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
linearLayout.setBackgroundResource(R.drawable.bg_landscape)
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
linearLayout.setBackgroundResource(R.drawable.bg_portrait)
}
}
val screenOrientation = this.resources.configuration.orientation
if (screenOrientation == Configuration.ORIENTATION_PORTRAIT) {
// TODO
} else {
// TODO
}