2011-09-22 16:24来源:武汉北大青鸟光谷校区作者:admin
在开发中我们经常需要把我们的应用设置为屏,这里我所知道的有俩中方法,一中是在代码中设置,另一种方法是在配置文件里改!
一、在代码中设置:
view plaincopy to clipboardprint?
package com.android.tutor;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class OpenGl_Lesson1 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//无title
requestWindowFeature(Window.FEATURE_NO_TITLE);
//屏
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
WindowManager.LayoutParams. FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
package com.android.tutor;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class OpenGl_Lesson1 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//无title
requestWindowFeature(Window.FEATURE_NO_TITLE);
//屏
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
WindowManager.LayoutParams. FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
在这里要强调一点,设置屏的俩段代码必须在setContentView(R.layout.main) 之前,不然会报错。
二、在配置文件里修改
(android:theme="@android:style/Theme.NoTitleBar.Fullscreen"):
view plaincopy to clipboardprint?
package="com.android.tutor"
android:versionCode="1"
android:versionName="1.0">< android:name=".OpenGl_Lesson1">
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name">< xmlns:android="http://schemas.android.com/apk/res/android">
package="com.android.tutor"
android:versionCode="1"
android:versionName="1.0">
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name">
Copyright (c) 2006-2021 武汉宏鹏教育咨询有限公司 版权所有 All Rights Reserved.