我想在我的应用程序中隐藏状态栏以使其全屏显示,所以我使用此示例隐藏通知栏- 它工作正常。但是如果我锁定屏幕然后解锁它,出现状态栏,如何解决这个问题?
问问题
2708 次
5 回答
1
要隐藏 Android 状态栏和应用程序标题栏,请将以下内容添加到清单文件中:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
例子:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.vogella.android.temperature"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Convert"
android:label="@string/app_name"
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>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>
更新
从锁屏返回后,还可以尝试将此代码放入您的相关活动中:
public class FullScreen extends Activity {
@Override
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);
}
}
于 2012-03-14T18:05:06.833 回答
1
如果安全不是问题,您可以在应用程序运行时禁用锁定屏幕。将以下行添加到清单中:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
在您的活动中,您可以执行以下操作:
public class MyActivity extends Activity {
private KeyguardLock lock;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Disable lock screen.
KeyguardManager keyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
lock = keyGuardManager.newKeyguardLock("MyActivity");
lock.disableKeyguard();
}
@Override
protected void onDestroy() {
super.onDestroy();
// Reenable the lock screen again.
lock.reenableKeyguard();
}
}
于 2012-07-13T10:15:32.127 回答
1
仅将其添加到样式中
<style name="AppTheme" parent="Theme.Design.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowFullscreen">true</item>
</style>
于 2018-05-08T18:37:56.380 回答
0
onCreate()
在之前使用此代码setContentView()
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
于 2012-08-05T12:00:50.537 回答
-2
将此代码写入应用程序标记的 mainfest.xml 文件中,如下所示:
<application android:name="application package"
android:label="application name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
于 2012-03-14T12:40:21.010 回答