简体   繁体   中英

android:screenOrientation ? Can you go landscape only on high resolution devices?

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

I can set the manifest.xml file for the activity to rotate based on the sensor, eg android:screenOrientation = "sensor" but this does not provide the behavior I'd like.

For instanced I'd like to allow a user to go to Landscape mode in a tablet device, but not on smaller resolution device (because the UI would look awful).

From what I can tell, there is no way to respond dynamically (eg at run time) if an orientation is acceptable. Or is there?

Am I missing something? Thanks in advance!

Could you do it with the resource folders:

For smaller landscape - default:

  /layout/main.xml

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

For high res allowing portrait:

 /layout-port-hdpi/main.xml 

main.xml will be portrait hdpi only

This is the article you can get idea's from: ResourceTypes

Providing resources specific to large streens is built into the Android resource XML. Resource directories may be suffixed with -<suffix> to qualify that they are specific to a class of device capability, locality, time of day, and more. Specifically, you'd be interested in the screen size qualifier, which supports the values large and xlarge for just the purpose of creating special conditions for screens larger than 4 and 7 inches respectively.

For specifics on how to support multiple screen sizes, see this guide which comes directly from the developer manual.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM