您好,欢迎来到叨叨游戏网。
搜索
您的当前位置:首页设置安卓设备屏幕方向,平板为横屏,手机为竖屏

设置安卓设备屏幕方向,平板为横屏,手机为竖屏

来源:叨叨游戏网

http://stackoverflow.com/questions/9627774/android-allow-portrait-and-landscape-for-tablets-but-force-portrait-on-phone

Here's a good way using  and .

Put this bool resource in res/values as bools.xml or whatever (file names don't matter here):

    <?xml version="1.0" encoding="utf-8"?> <resources> <bool name="portrait_only">true</bool> </resources>

Put this one in res/values-sw600dp and res/values-xlarge:

    <?xml version="1.0" encoding="utf-8"?> <resources> <bool name="portrait_only">false</bool> </resources>

Then, in the onCreate method of your Activities you can do this:

    if(getResources().getBoolean(R.bool.portrait_only)){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }

Devices that are more than 600 dp in the smallest width direction, or x-large on pre-Android 3.2 devices (tablets, basically) will behave like normal, . Everything else (phones, pretty much) will be portrait only.

转载于:https://www.cnblogs.com/zwliuxing/p/39674.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- gamedaodao.net 版权所有 湘ICP备2024080961号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务