I use View.setRotationY() to rotate my views according to the orientation of the device. Everything works well while in portrait. But when the device is rotated, the layout's background gets distorted.
code:
if(under == RecyclerView.NO_POSITION){
aboveBinding.vContainerLeft.rotationY = 0F
aboveBinding.vContainerRight.rotationY = 0F
}else if(under == above - 1){
val half = width / 2
val degrees = 90 * ((width - offset).toFloat() / half)
aboveBinding.vContainerLeft.pivotX = aboveBinding.vContainerLeft.width.toFloat()
aboveBinding.vContainerLeft.rotationY = degrees
aboveBinding.vContainerRight.rotationY = 0F
}else{
val half = width / 2
val degrees = -90 * (offset.toFloat() / half)
aboveBinding.vContainerRight.pivotX = 0F
aboveBinding.vContainerLeft.rotationY = 0F
aboveBinding.vContainerRight.rotationY = degrees
}
When I use View.setRotationY() method to set the angle between -60 deg and -90 deg, I expect the background to look like thisangle in 0 ~ -60. But, it turns out like thisangle in -60 ~ -90
Again, when I set the angle between 75 deg and 90 deg, I expect the background to look like thisangle in 0 ~ 75. But, it turns out like thisangle in 75 ~ 90
How do I rectify this..?