What I would like to do:
Just to clarify, I want to know what orientation the layout is currently in. Which direction is the bottom of the layout? Is it in portrait? Is it in landscape? Is the landscape left or right? etc.
The closest I can find is Activity.getResources().getConfiguration().orientation, but it only returns three possible values. ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT, or ORIENTATION_SQUARE. It does not say which type of landscape.
So, then I thought, well if I can get the orientation value (like 90, 180, 270, etc) of the device and compare it to the above config value I could figure it out. For example, if the config value was ORIENTATION_LANDSCAPE and the orientation was 270, I could tell that it was in the reverse landscape mode. However, there doesn't appear to be an easy way to get the orientation value. I could implement an OrientationEventListener, but that seems overkill since I just need to get the value once at a specific time, not constantly.
There are two values in the Display class but getOrientation is deprecated and getRotation is only available for 2.2 and above.
Now, even if I did get this value, there is still the issue of devices that are naturally landscape. Meaning their 0 value would be landscape instead of portrait. So I also need a sure way to tell which (landscape-left, landscape-right or portrait) corresponds to 0.
There are a lot of posts on SO about orientation and similar issues, but I haven't seen any that take all of these issues into consideration. Has anyone figured this out?
When all is said and done I would like something like Activity.getResources().getConfiguration().orientation but be able to tell which landscape mode it is.
Right landscape wasn't supported till 2.2. You'll need to have <2.2 devices choose in the options or something.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With