`
无尘道长
  • 浏览: 157942 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Activity 的属性之android:screenOrientation(转)

阅读更多

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

 

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

 

 

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

分享到:
评论

相关推荐

    Android XML設置屏幕方向(android:screenOrientation)详解

    Android XML設置屏幕方向(android:screenOrientation)详解 注意:Android只支持270度旋转。 &lt;activity android:name=.MyActivity android:label=@string/app_name android:screenOrientation=portrait&gt; android...

    Android代码-仿微信app.rar

    android:screenOrientation="portrait" android:theme="@style/horizontal_slide" android:windowSoftInputMode="adjustResize"&gt;&lt;/activity&gt; &lt;activity android:name=...

    android 横竖屏限制的配置方法

    只需要在AndroidManifest.xml文件中加入android:screenOrientation属性限制。ndroid:screenOrientation=”landscape”是限制此页面横屏显示, ndroid:screenOrientation=”portrait”是限制此页面数竖屏显示。 例如...

    Android禁止横屏竖屏切换的有效方法

    在AndroidManifest.xml的activity(需要禁止转向的activity)配置中加入android:screenOrientation=”landscape”属性即可(landscape是横向,portrait是纵向)。例如:  &lt;?xml version=1.0 encoding=utf-8?&gt; &...

    android视频旋转相关知识总结

    当数据量较大时,在屏幕旋转时,一般都采用两种方式避免Activity从新... 如果不想让软件在横竖屏之间切换,最简单的办法就是在项目的 AndroidManifest.xml中找到你所指定的Activity中加上android:screenOrientation属性

    Android屏幕旋转适配

    代码解析 http://blog.csdn.net/leejizhou/article/details/51233342

    fullSensor

    Expecting ‘android:screenOrientation=”unspecified”‘ or ‘”fullSensor”‘ for this activity so the user can use the application in any orientation and provide a great experience on Chrome OS ...

    Android横竖屏切换实例总结

    Android横竖屏切换在手机开发中比较常见,很多软件在开发过程中为了避免横竖屏切换时引发不必要的麻烦,通常禁止掉横竖屏的切换,即通过在AndroidManifest.xml中设置activity中的android:screenOrientation属性值来...

    android 横竖屏切换生命周期

    为了避免activity 重新加载过程中有闪屏的现象,则需要再清单文件中配置该activity 的属性 android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation|screenSize",详细信息请参阅...

    Activity代理框架AyoActivityNoManifest.zip

     android:theme="@style/AyoTransparentTheme" /&gt; (2) ActivityAttacherActivityAttacher的意义:ActivityAttacher就是附着在上面4个模板Activity里的Activity代理ActivityAttacher中持有一个Activity实例对象,...

    Android 屏幕横竖切换详解

    Android 里面控制Activity的方向,只要在AndroidManifest.xml里面对应的Activity节点下加一句 android:screenOrientation=”landscape”(landscape是横屏,portrait竖屏)。  我凭这句话混了一年,基本都可以的,...

    Android之横竖屏切换

    android:screenOrientation属性,有以下几个参数: "landscape": 横屏显示 (宽比高长) "portrait": 竖屏显示 (高比宽长)

    Android冷启动实现app秒开的实现代码

    AndroidManifest里对应activity添加属性android:theme=”@style/AppSplash” &lt;activity android:name=com.senyint.edu.college.stu.view.activity.SplashActivity android:screenOrientation=portrait android:...

    Android 屏幕实现上下翻转

    通常我们的应用只会设计成横屏或者竖屏,锁定横屏或竖屏的方法是在manifest.xml文件中设定属性android:screenOrientation为”landscape”或”portrait”: &lt;activity android:name=com.example.kata1.MainActivity...

    android 判断横竖屏问题的详解

    1.布局问题:如果不想让软件在横竖屏之间切换,最简单的办法就是在项目的 AndroidManifest.xml中找到你所指定的activity中加上android:screenOrientation属性,他有以下几个参数:“unspecified” 默认值 由系统来...

    Android Zxing 转换竖屏扫描且提高识别率的方法

    AndroidManifest.xml中把activity标签CaptureActivity部分的screenOrientation改为portrait。 android:screenOrientation=portrait 2&gt;. CameraManager类中的getFramingRectInPreview()方法,将left, right, top...

    Android调用第三方QQ登录代码分享

    本文为大家分享了调用QQ登录的相关代码,希望对大家有帮助,减少项目开发的时间,具体内容如下 ... 2、在Manifest.xml里注册QQ相关的Activity,...android:screenOrientation=portrait android:theme=@android:style/Them

    Andriod开发中常见问题

    本文为大家总结了Andriod开发中常遇到的问题,供大家学习,具体内容如下 1.Andriod中布局中引用布局的问题 (使用如下方法即可,布局中引用布局可以起到节省资源的问题) ...android:screenOrientation=portrait //屏

    uCrop:Android图像裁剪库

    uCrop-Android图像裁剪库该项目旨在提供最终且灵活的图像裁剪体验。...activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait" android:theme="@style/Them

Global site tag (gtag.js) - Google Analytics