M
M
Michaelxn2016-03-25 20:59:25
Android
Michaelxn, 2016-03-25 20:59:25

How to make different screen orientation for phone and tablet?

What to prescribe so that the screen orientation in the application on the phone is only portrait, and on the tablet both portrait and landscape (that is, on the tablet it depends on the rotation of the device, but not on the phone)? For now, I’m prescribing in the manifest so that the orientation is always portrait, but on a tablet it’s not always convenient, and on a phone, only portrait orientation is required.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2016-03-25
@Mihailxn

Determine that you are dealing with a tablet, for example, like this:

public static boolean isTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout 
& Configuration.SCREENLAYOUT_SIZE_MASK)
            >= Configuration.SCREENLAYOUT_SIZE_LARGE;
}

Request the desired screen orientation - setRequestedOrientation()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question