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

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

Here‘s a good way using resources and size qualifiers.

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"?>true

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

<?xml version="1.0"encoding="utf-8"?>false

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, based on sensor and user-locked rotation, etc. Everything else (phones, pretty much) will be portrait only.

原文:http://www.cnblogs.com/zwliuxing/p/3899674.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值