I have a situation, wherein, if the Android device is a tablet, then I want the orientation to be enabled (portrait and landscape), whereas if the device is a phone, I want the orientation to be only in Portrait mode. Can you help me how to do this?
Thanks, Nithin
Screen Orientation, also known as screen rotation, is the attribute of activity element in android. When screen orientation change from one state to other, it is also known as configuration change. There are various possible screen orientation states for any android application, such as: ActivityInfo.
int orientation = display. getOrientation(); Check orientation as your way and use this to change orientation: setRequestedOrientation (ActivityInfo.
You have 2 methods :
a) Create different sets of layout and drawables for the phone and tablet separately and design them according to the orientation you need.
b) Check for the operating device during runtime and set the orientation. To check the device , give a check on the following parameters and set the orientation programatically,
(1) Build.VERSION.SDK_INT
(2) Configuration.SCREENLAYOUT_SIZE_MASK
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