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

Asked 1 years ago, Updated 1 years ago, 96 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.