android开发 全屏 隐藏电池等信息
来源:互联网 发布:淘宝电子发票如何打印 编辑:程序博客网 时间:2024/05/14 10:57
requestWindowFeature(Window.FEATURE_NO_TITLE);(隐藏title导航栏)
看一下我们实际使用this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
隐藏信息状态栏
运行以上程序会产生如下错误:public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//全屏
setContentView(new DrawBitmapTest(this));this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
我们查看源码提示java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dream.sur/com.dream.sur.draw.SurfaceViewTestActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:189)
at android.app.Activity.requestWindowFeature(Activity.java:2735)
意思是说 requestWindowFeature 必须在 setContentView() 这个方法之前调用,后面使之 setFlags 的设置需要在 setContentView();Enable extended screen features. This must be called before setContentView().
Note that some flags must be set before the window decoration is created (by the first call to {@link #setContentView(View, android.view.ViewGroup.LayoutParams)
将title栏和时间电池信息状态栏给隐藏掉public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(new DrawBitmapTest(this));
}
如果想要仅去除title栏留下时间和电池信息状态栏可以将以上xml theme换成:<activity
android:name=".draw.SurfaceViewTestActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
至此android全屏的设置已经okandroid:theme="@android:style/Theme.NoTitleBar"
public final boolean requestWindowFeature(int featureId) {
return getWindow().requestFeature(featureId);
}转自:http://dreamthinking.blog.163.com/blog/static/205181171201251973349985/
- android开发 全屏 隐藏电池等信息
- 隐藏Android模拟器中的标题栏和电池等图标
- iOS7隐藏电池时间等
- IOS开发 隐藏电池栏 (电池状态栏)
- Android 获取电池信息
- Android获取电池信息
- android 电池信息
- Android 获取电池信息
- Android电池信息
- Android 获取电池信息
- Android 获取电池信息
- Android 开发范例——7.电池状态信息查看
- IOS下隐藏电池等statusBar
- android全屏,隐藏状态栏
- Android隐藏状态栏 全屏
- Android 隐藏状态栏部分 (电池等图标和一切修饰部分)
- Android电池信息获得问题
- Android电池信息的获取
- 第六篇 ANDROID窗口系统机制之显示机制与架构
- Ant全面了解(包括taskdef和environment)
- unix网络编程-十二,十三章-小结
- 从网络字节流中读取4个字节拼装,返回long
- HDOJ2853-KM匹配,放大技巧
- android开发 全屏 隐藏电池等信息
- 从网络字节流中读取2个字节拼装成为short
- Create tablespace in Oracle
- Andriod+phonegap实现显示手机所在地天气
- 我的博客迁移到 http://jasonli.info
- public static void Word2Byte(byte[] to, int toIndex, short from) {
- public static void DWord2Byte(byte[] to, int toIndex, long from) {
- HDU 3650 Hot Expo
- 闲来打油诗一首