How to lock the screen to remain vertical/portrait? When screen rotate lock is off, the screen on my tablet has four possible orientations: A, B, C, and D, as illustrated below:



I know that it is possible to lock the screen to one orientation -- A or B or C or D -- by deselecting the screen rotation icon in the Notifications pulldown:



But I want to lock the screen so that it is always in either the A or the C orientation (vertical/portrait), and never in the B or D orientation (horizontal/landscape).  In other words, I want the screen to always be oriented vertically, but still respecting the particular vertical orientation (gravity).

Is this possible?

You might wonder why I want to do this -- I am physically disabled, and it would (really help me out if this were somehow possible.  I'm running Android 7.1.1 on a Samsung Galaxy Tab A (2017).)
It looks like the app called "Ultimate Rotation Control" will do what you are asking. Here's the link:
Ultimate Rotation Control