指定Activity的默认显示方向

简介: 指定Activity的默认显示方向

在Manifest文件中指定 screenOrientation

android:screenOrientationThe orientation of the activity's display on the device. The system ignores this attribute if the activity is running in multi-window mode.

The value can be any one of the following strings:

<activity>  |  Android Developers (google.cn)

 

Activity在屏幕当中显示的方向。属性值可以是下表中列出的一个值:

  1. “unspecified” 默认值,由系统来选择方向。它的使用策略,以及由于选择时特定的上下文环境,可能会因为设备的差异而不同。
  2. “user” 使用用户当前首选的方向。
  3. “landscape” 横向显示(宽度比高度要大)
  4. “portrait” 纵向显示(高度比宽度要大)
  5. “reverseLandscape” 与正常的横向方向相反显示,在API Level 9中被引入。
  6. “reversePortrait” 与正常的纵向方向相反显示,在API Level 9中被引入。
  7. “sensorLandscape” 横向显示,但是基于设备传感器,既可以是按正常方向显示,也可以反向显示,在API Level9中被引入。
  8. “sensorPortrait” 纵向显示,但是基于设备传感器,既可以是按正常方向显示,也可以反向显示,在API Level 9中被引入。
  9. “sensor” 显示的方向是由设备的方向传感器来决定的。显示方向依赖与用户怎样持有设备;当用户旋转设备时,显示的方向会改变。但是,默认情况下,有些设备不会在所有的四个方向上都旋转,因此要允许在所有的四个方向上都能旋转,就要使用fullSensor属性值。
  10. “fullSensor” 显示的方向(4个方向)是由设备的方向传感器来决定的,除了它允许屏幕有4个显示方向之外,其他与设置为“sensor”时情况类似,不管什么样的设备,通常都会这么做。例如,某些设备通常不使用纵向倒转或横向反转,但是使用这个设置,还是会发生这样的反转。这个值在API Level 9中引入。
  11. “nosensor” 屏幕的显示方向不会参照物理方向传感器。传感器会被忽略,所以显示不会因用户移动设备而旋转。除了这个差别之外,系统会使用与“unspecified”设置相同的策略来旋转屏幕的方向。

注意:在给这个属性设置的值是“landscape”或portrait的时候,要考虑硬件对Activity运行的方向要求。正因如此,这些声明的值能够被诸如Google Play这样的服务所过滤,以便应用程序只能适用于那些支持Activity所要求的方向的设备。例如,如果声明了“landscape”、“reverseLandscape”、或“sensorLandscape”,那么应用程序就只能适用于那些支持横向显示的设备。但是,还应该使用元素来明确的声明应用程序所有的屏幕方向是纵向的还是横行的。例如:<uses-feature android:name=”android.hardware.screen.portrait”/>。这个设置由Google Play提供的纯粹的过滤行为,并且在设备仅支持某个特定的方向时,平台本身并不控制应用程序是否能够被按照。

 

"unspecified" The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, might differ from device to device.
"behind" The same orientation as the activity that's immediately beneath it in the activity stack.
"landscape" Landscape orientation (the display is wider than it is tall).
"portrait" Portrait orientation (the display is taller than it is wide).
"reverseLandscape" Landscape orientation in the opposite direction from normal landscape. Added in API level 9.
"reversePortrait" Portrait orientation in the opposite direction from normal portrait. Added in API level 9.
"sensorLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor. The sensor is used even if the user has locked sensor-based rotation. Added in API level 9.
"sensorPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor. The sensor is used even if the user has locked sensor-based rotation. However, depending on the device configuration, upside-down rotation might not be allowed. Added in API level 9.
"userLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor and the user's preference. Added in API level 18.
"userPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor and the user's preference. However, depending on the device configuration, upside-down rotation might not be allowed. Added in API level 18.
"sensor" The device orientation sensor determines the orientation. The orientation of the display depends on how the user is holding the device. It changes when the user rotates the device. Some devices, though, don't rotate to all four possible orientations, by default. To use all four orientations, use "fullSensor". The sensor is used even if the user locked sensor-based rotation.
"fullSensor" The device orientation sensor determines the orientation for any of the four orientations. This is similar to "sensor", except this allows for any of the four possible screen orientations regardless of what the device normally supports. For example, some devices don't normally use reverse portrait or reverse landscape, but this enables those orientations. Added in API level 9.
"nosensor" The orientation is determined without reference to a physical orientation sensor. The sensor is ignored, so the display doesn't rotate based on how the user moves the device.
"user" The user's current preferred orientation.
"fullUser" If the user has locked sensor-based rotation, this behaves the same as user, otherwise it behaves the same as fullSensor and allows any of the four possible screen orientations. Added in API level 18.
"locked"

Locks the orientation to its current rotation, whatever that is. Added in API level 18.


目录
相关文章
|
10月前
|
Kubernetes 应用服务中间件 nginx
最全的kubectl命令用法
本文系统讲解kubectl命令行工具:详解所有子命令(创建、查询、部署、调试等)、API资源列表、自动补全配置,并通过大量实操示例(如创建/查看/编辑/删除资源、扩缩容、回滚、标签管理等)助你快速掌握Kubernetes集群管理核心技能。(239字)
1311 143
|
人工智能 监控 测试技术
告别只会写提示词:构建生产级LLM系统的完整架构图​
本文系统梳理了从提示词到生产级LLM产品的八大核心能力:提示词工程、上下文工程、微调、RAG、智能体开发、部署、优化与可观测性,助你构建可落地、可迭代的AI产品体系。
1570 52
|
编译器 API 定位技术
API和SDK的区别
API 和 SDK 的区别在于:API 是一组定义了软件组件之间交互规范的接口,用于实现不同软件组件之间的通信;而 SDK 是一个全面的工具集合,包含 API、编译器、调试器、文档等,用于特定平台的应用程序开发。SDK 范围更广,内容更丰富,更具体和具象化,适合复杂的开发需求;API 则更加抽象,侧重于功能的定义和调用方式。
|
人工智能 搜索推荐 API
AI-Compass DeepSearch深度搜索生态:集成阿里ZeroSearch、字节DeerFlow、MindSearch等前沿平台,实现超越传统关键词匹配的智能信息检索革命
AI-Compass DeepSearch深度搜索生态:集成阿里ZeroSearch、字节DeerFlow、MindSearch等前沿平台,实现超越传统关键词匹配的智能信息检索革命
AI-Compass DeepSearch深度搜索生态:集成阿里ZeroSearch、字节DeerFlow、MindSearch等前沿平台,实现超越传统关键词匹配的智能信息检索革命
|
边缘计算 人工智能 云计算
HIS系统的核心模块:医生工作站
医生工作站是HIS系统的核心模块,围绕诊疗流程一体化、电子病历智能化、医嘱闭环管理、辅助决策支持及移动化操作五大方面优化医疗流程。它整合患者信息,提供结构化病历生成与质控,实现医嘱全流程追踪,结合药品和诊疗知识库辅助决策,并支持多场景便捷操作。通过数据整合与智能工具,提升诊疗效率与质量,助力智慧医疗发展。
1045 2
|
机器学习/深度学习 算法 大数据
【BetterBench博士】2024 “华为杯”第二十一届中国研究生数学建模竞赛 选题分析
2024“华为杯”数学建模竞赛,对ABCDEF每个题进行详细的分析,涵盖风电场功率优化、WLAN网络吞吐量、磁性元件损耗建模、地理环境问题、高速公路应急车道启用和X射线脉冲星建模等多领域问题,解析了问题类型、专业和技能的需要。
6362 22
【BetterBench博士】2024 “华为杯”第二十一届中国研究生数学建模竞赛 选题分析
|
机器学习/深度学习 人工智能 自然语言处理
Java+机器学习基础:打造AI学习基础
随着人工智能(AI)技术的飞速发展,越来越多的开发者开始探索如何将AI技术应用到实际业务场景中。Java作为一种强大的编程语言,不仅在企业级应用开发中占据重要地位,在AI领域也展现出了巨大的潜力。本文将通过模拟一个AI应用,从背景历史、业务场景、优缺点、底层原理等方面,介绍如何使用Java结合机器学习技术来打造一个AI学习的基础Demo。
761 18
|
消息中间件 Java Apache
手把手教你使用Idea调试RocketMQ源码
手把手教你使用Idea调试RocketMQ源码
1096 0
手把手教你使用Idea调试RocketMQ源码
|
人工智能 自然语言处理 前端开发
从客服场景谈:大模型如何接入业务系统
本文探讨了大模型在AI客服中的应用。大模型虽具有强大的知识生成能力,但在处理具体业务如订单咨询、物流跟踪等问题时,需结合数据库查询、API调用等手段。文章提出用Function Call连接大模型与业务系统,允许大模型调用函数获取私域知识。通过具体示例展示了如何设计系统提示词、实现多轮对话、定义Function Call函数,并利用RAG技术检索文档内容。最后,展示了该方案在订单查询和产品咨询中的实际效果。
盒式交换机又是如何配置堆叠的呢?
盒式交换机又是如何配置堆叠的呢?
546 1

热门文章

最新文章