简体   繁体   English

如何检测在某些 android 设备中无法更改活动轮换?

[英]How to detect that changing activity rotation is not possilbe in some android devices?

I am working on an android app that is used on both Android mobile and Android TV devices.我正在开发一个 android 应用程序,该应用程序用于 Android 移动设备和 Android 电视设备。 I have a portrait activity.我有一个肖像活动。 It works well on normal mobile but on Android Tv devices, it shows a rotated portrait screen in landscape mode.它在普通手机上运行良好,但在 Android 电视设备上,它在横向模式下显示旋转的纵向屏幕。 So, is there any way to force the activity to be in portrait mode?那么,有没有办法强制活动处于纵向模式? If it's not possible, how can I detect that the device does not support different orientations?如果不可能,我如何检测到设备不支持不同的方向?

P/s: I did add this android:screenOrientation="portrait" to the AndroidManifest file. P/s:我确实将这个android:screenOrientation="portrait"添加到 AndroidManifest 文件中。

图片

You have to add below line each activity tag of yours in your Android manifest file您必须在 Android 清单文件中添加您的每个活动标签

android:screenOrientation="portrait"

You should not run an activity in portrait mode on the TV.您不应在电视上以纵向模式运行活动。 That goes against the TV-LO quality requirement and your app submission will be rejected if you submit to Google Play like that.这违反了TV-LO 质量要求,如果您像这样提交到 Google Play,您的应用提交将被拒绝。 On top of that, overscan will cut off part of your layout on some displays, so the user experience will not be good.最重要的是,过度扫描会在某些显示器上切断部分布局,因此用户体验不会很好。

I'd recommend creating a landscape layout or optimizing your portrait layout to work in landscape mode.我建议创建横向布局或优化纵向布局以在横向模式下工作。 Even without TV, you're going to run into user experience issues forcing an orientation (eg, on a tablet that's in landscape mode because a keyboard is connected).即使没有电视,您也会遇到强制方向的用户体验问题(例如,在平板电脑上因为连接了键盘而处于横向模式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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