How do I check if my Android phone is horizontal or vertical?

Asked 2 years ago, Updated 2 years ago, 110 views

How do I check if my Android phone is horizontal or vertical?

android java orientation

2022-09-21 17:06

1 Answers

if(getResources().getConfiguration().orientation == Configuration.
                ORIENTATION_LANDSCAPE) {
            layout = R.layout.main;
        } } else if (getResources().getConfiguration().orientation == Configuration.
                ORIENTATION_PORTRAIT) {
            layout = R.layout.main;
        }

You can do it like this.


2022-09-21 17:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.