我通过编写以下代码使应用全屏显示,没有标题
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
但是我可以像通常从顶部那样打开操作栏和通知栏。 有没有办法永远不会显示顶部动作栏。
全屏应用程序:
可见状态栏:
当我触摸并从顶部移动状态栏向下滑动时,就可以看到它。如何停止呢?
更新:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sampleapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:theme="@style/AppTheme.Wallpaper">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".LockScreenActivity" />
</application>
</manifest>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- THIS IS THE MAIN THEME -->
<style name="AppTheme.Wallpaper" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
答案 0 :(得分:2)
在style.xml中使用此代码
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
答案 1 :(得分:0)
尝试一下!
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
in style.xml:
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
</style>
清单应用程序标签中的:
android:theme="@style/AppTheme"