肖像用于手机,景观的平板电脑(Android的布局)肖像、平板、布局、景观

由网友(离线请留言……)分享简介:所以,我正在为Android应用程序,我想迫使横向方向的平板电脑和纵向方向的手机。不过,好像我只能这样做,从我所看到的这违背了希望两个独立的方向进行设备的目的的方向锁定。So I'm making an application for Android and I want to force Landscape ori...

所以,我正在为Android应用程序,我想迫使横向方向的平板电脑和纵向方向的手机。不过,好像我只能这样做,从我所看到的这违背了希望两个独立的方向进行设备的目的的方向锁定。

So I'm making an application for Android and I want to force Landscape orientation for tablets and Portrait orientation for phones. However, it seems as though I can only do an orientation lock from what I've seen which defeats the purpose of wanting two separate orientations for devices.

片:风景 电话:人像

要说得更多的技术。

我在RES /布局XLARGE陆的美化在平板电脑上的布局,我有原来的布局中RES /布局,我只是想明确地使用布局XLARGE陆为片剂。闲来无事,基本上只用景观的XLARGE设备。

I have a layout in "res/layout-xlarge-land" for landscaping on the tablet and I have the original layout in "res/layout" and I just want to explicitly use layout-xlarge-land for the tablet. Nothing else, essentially ONLY using landscape for xlarge devices.

谢谢!

推荐答案

设置基于设备的密度一个特定的方向可能无法正常工作,因为有手机具有更高的密度比平板电脑。

Setting a particular orientation based on device density may not work because there are phones which have higher densities than tablets.

我所做的就是通过设置活动标记的属性清单文件中像这样来禁用该设备的方向感应器:

What I did was to disable the device's orientation sensor by setting the attribute in the activity tag in the manifest file like this:

android:screenOrientation="nosensor"

当你运行你的应用程序,默认情况下纵向设置为手机和景观为平板电脑(因此它会选择从XML文件布局XLARGE陆 )。而且,由于你设置的方向锁,它仍然在这个方向。

When you run your app, by default portrait orientation is set for phones and landscape for tablets(and hence it'll select the xml file from layout-xlarge-land). And since you've set an orientation lock, it remains in this orientation.

阅读全文

相关推荐

最新文章