Android设置全屏的方法
来源:互联网 发布:ubuntu系统官网 编辑:程序博客网 时间:2024/04/28 12:06
在开发中我们经常需要把我们的应用设置为全屏,这里我所知道的有俩中方法,一中是在代码中设置,另一种方法是在配置文件里改!
一、在代码中设置:
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?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.tutor"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".OpenGl_Lesson1"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.tutor"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".OpenGl_Lesson1"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
在这里我还想说明一下,用前者在我们应用运行后,会看到短暂的状态栏,然后才全屏,而第二种方法是不会有这种情况的,所以我建议
大家使用后者! 谢谢~
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Android_Tutor/archive/2010/05/03/5553632.aspx
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ghd2000/archive/2010/07/08/5721473.aspx
- Android设置全屏的方法
- Android设置全屏的方法
- Android设置全屏的方法
- Android设置全屏的方法
- Android设置全屏的方法
- Android设置全屏的方法
- Android设置全屏的方法
- android设置全屏以及解决设置全屏无效的方法
- Android设置全屏方法
- Android中两种设置全屏的方法!!!
- Android中设置全屏的方法
- Android两种设置全屏的方法
- Android中两种设置全屏的方法
- Android中设置全屏的方法
- Android中设置全屏的方法
- Android中设置全屏的方法
- Android中两种设置全屏的方法!!!
- Android中设置全屏的方法
- 贪吃蛇
- 访问android平台的通话记录CallLog
- nagios 命令
- flash 使用as2.0 取消字符串首尾空格 自定义trim()
- linu查找文件命令
- Android设置全屏的方法
- 同时获得一个序列的最小和最大值的方法
- php url rewrite
- Java中格式化日期时间的类:SimpleDateFormat 用法详解
- 国外空间Access错误Selected collating sequence not supported by the operating system
- List Control 初始化时显示网格和颜色
- linux shell编程模拟用户登录
- 图片(旋转/缩放/翻转)变换效果(ccs3/滤镜/canvas)
- liveCD 修复grub