使用样式设置活动屏幕方向
我正在尝试使用样式设置活动屏幕方向:
这是 styles.xml:
...
<style name="Some.Activity" parent="android:Theme">
<item name="android:screenOrientation">portrait</item>
</style>
...
这是 AndroidManifest.xml 中的活动声明:
<activity android:name="SomeActivity" android:theme="@style/Some.Activity"/>
但它不起作用。
我知道我可以
<activity android:name="SomeActivity" android:theme="@style/Some.Activity"
android:screenOrientation="..."/>
在清单中设置,但使用主题来做到这一点对我来说很重要。
有想法吗?
I'm trying to set activity screen orientation using a styles:
Here is the styles.xml:
...
<style name="Some.Activity" parent="android:Theme">
<item name="android:screenOrientation">portrait</item>
</style>
...
and here is activity declaration in AndroidManifest.xml:
<activity android:name="SomeActivity" android:theme="@style/Some.Activity"/>
and it doesn't work.
I know that I can just set
<activity android:name="SomeActivity" android:theme="@style/Some.Activity"
android:screenOrientation="..."/>
in the manifest, but its important to me to do that using a theme.
Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://developer.android.com/guide/practices/screens_support.html
此链接可能有帮助。基本上,您必须为每个方向制作不同的布局文件,并将它们放入相应的布局土地或布局端口文件夹中。您还可以为不同屏幕尺寸上的不同方向创建布局。例如,如果横向模式下“正常”尺寸屏幕的所有控件不适合小屏幕,您可以创建一个名为layout-small-land 的文件夹并拥有另一个自定义布局文件。
http://developer.android.com/guide/practices/screens_support.html
This link may help. Basically you have to make different layout files for each orientation and put them in corresponding layout-land or layout-port folders. You can also create layouts for different orientations on different screen sizes. For example, if not all of the controls you have for a "normal" sized screen in landscape mode fit on a small screen you can create a folder named layout-small-land and have another customized layout file.
在这里修改我的答案:这似乎不受支持,并非所有属性都是样式属性。
Revising my answer here: this seems not to be supported, not all attributes are styled ones.