Android: screenOrientation? Can you go to the landscape only on high-resolution devices?

Is there a way to allow landscape only on a large device?

I can set the manifest.xml file for the activity for rotation based on the sensor, for example android: screenOrientation = "sensor", but this does not provide the behavior I would like.

For instanced, I would like to allow the user to switch to landscape mode on the tablet device, but not on the device of lower resolution (because the user interface will look awful).

From what I can say, there is no way to dynamically react (for example, at runtime) if the orientation is acceptable. Or is there?

Am I missing something? Thanks in advance!

+4
source share
2 answers

Could you do this with resource folders:

For a smaller landscape - default:

/layout/main.xml 

main.xml root layout: orientation = "portrait" (forcing the portrait here, not in the manifest)

For high resolution portrait resolution:

  /layout-port-hdpi/main.xml 

main.xml will only portrait hdpi

This is an article you can get from: ResourceTypes

+2
source

The provision of resources specific to large racks is built into the Android XML resource. Resource directories can be suffixed with -<suffix> to determine that they belong to the class of device capabilities, locality, time of day, etc. In particular, you will be interested in a screen size specifier that supports large and xlarge values ​​only to create special conditions for screens larger than 4 and 7 inches, respectively.

For details on how to support multiple screen sizes, see this guide , which comes directly from the developer’s guide.

+1
source

All Articles