Rotate the phone to horizontal and be sure not to touch the screen (it won't rotate while being touched). If it doesn't work, you can see if the phone's accelerometer is working properly.
The Galaxy Z Flip and the Motorola Razr ... said the upper layer of the Razr's screen separated from the bottom, creating "a giant horizontal air bubble" for no apparent reason.