acivity 横屏_Android游戏开发学习(1)--android设置全屏和横屏

横屏设置

XML文件设置--portrait为纵向,landscape为横向

android:screenOrientation="portrait"

android:screenOrientation=["unspecified" | "user" | "behind" |

"landscape" | "portrait" |

"sensor" | "nonsensor"]

screenOrientation 用来指定Activity的在设备上显示的方向,每个值代表如下含义:

"unspecified"     默认值 由系统来判断显示方向.判定的策略是和设备相关的,所以不同的设备会有不同的显示方向.

"landscape"     横屏显示(宽比高要长)

"portrait"     竖屏显示(高比宽要长)

"user"     用户当前首选的方向

"behind"     和该Activity下面的那个Activity的方向一致(在Activity堆栈中的)

"sensor"     有物理的感应器来决定。如果用户旋转设备这屏幕会横竖屏切换。

"nosensor"     忽略物理感应器,这样就不会随着用户旋转设备而更改了 ( "unspecified"设置除外 )。

代码设置

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

全屏两种方法:

方法一:

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//设置无标题

requestWindowFeature(Window.FEATURE_NO_TITLE);

//设置全屏

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.main);

}

方法二:

package="com.andyidea"

android:versionCode="1"

android:versionName="1.0" >

android:icon="@drawable/icon"

android:label="@string/app_name" >

android:name=".login.LoginActivity"

android:label="@string/app_name"

android:theme="@android:style/android.NoTitleBar.Fullscreen" >

分享到:

2012-02-14 16:09

浏览 5564

评论

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值